From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 38D5C6E1D1; Tue, 24 Nov 2026 10:58:23 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 38D5C6E1D1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1795507103; bh=CrllCSByY+wtVuxqaUoJI7cTUiPqHigAaQtHcT5DrE4=; h=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=x1ns3z7H7uyVu2MOmUAqgnHHFJYdKG77kVBSahOViVx/MMMldpNNrZzSCRSIHw2wc PFaZahC448iSAboSJobGy8QVzOeHSv3VdP5TtRwqxotjQ5WbYMAZWXElQL5j4eJRyw AAVuUuigzI0ncw2qmwPthfT2yj+nsp9UF4ajkiLA= Received: from send279.i.mail.ru (send279.i.mail.ru [95.163.59.118]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 9CC776E1D1 for ; Tue, 24 Nov 2026 10:58:22 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 9CC776E1D1 Received: by exim-smtp-canary-30-7cf57c478c-hmbt5 with esmtpa (envelope-from ) id 1xVlPw-00000000Rfc-3lVZ; Tue, 24 Nov 2026 10:58:21 +0300 Date: Tue, 24 Nov 2026 11:00:38 +0300 To: Sergey Bronnikov Message-ID: References: <20261118084808.3591198-1-skaplun@tarantool.org> <79a76da9-a60f-41f6-b3bc-dcae4faa1ed1@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <79a76da9-a60f-41f6-b3bc-dcae4faa1ed1@tarantool.org> X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9DFC18640EC9820975275C27875E8B4E424D398147D189020182A05F5380850400B2639BFF3A044BC3DE06ABAFEAF67058E5FB3E8BB0A91F7B7A1F1CAA28ABB125C562C83BEF8E994 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE78E88BD1CA827EF00C2099A533E45F2D0395957E7521B51C2CFCAF695D4D8E9FCEA1F7E6F0F101C6759CC434672EE6371C2A783ECEC0211ADC4224003CC836476D5A39DEEDB180909611E41BBFE2FEB2BDCC7DAD7475FCF9F123CE01087098EFFC84C475A665521F26861109A540FFC229FA2833FD35BB23D27C277FBC8AE2E8B5FC25ED3FCEC3375A471835C12D1D977C4224003CC8364762BB6847A3DEAEFB0F43C7A68FF6260569E8FC8737B5C2249EC8D19AE6D49635B68655334FD4449CB9ECD01F8117BC8BEAAAE862A0553A39223F8577A6DFFEA7CA35FE21102777C0943847C11F186F3C59DAA53EE0834AAEE X-C1DE0DAB: 0D63561A33F958A5A13054D68873C6E65002B1117B3ED69647DD0AEAB68A9C3B5D145BB8EF0DE66B823CB91A9FED034534781492E4B8EEAD9DB614F8F96CFA30BDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0AD73CAD6646DEDE1918E10F71CB4DF9F96AB70F9BE574AE9C625B6776AC983F447FC0B9F89525902EE6F57B2FD27647F25E66C117BDB76D659AB59AE26853DB3D4150CFC3A01CE8303B9863ADE95200156EA418E610E1476C37EF9A316C4A2F836B8341EE9D5BE9A0AF3F8577B8A80B329533544B1805ADDB50205599E770238B06536EB022892E5344C41F94D744909CECFA6C6B0C050A61A8CAF69B82BA93681CD72808BE417F3B9E0E7457915DAA85F X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXOcIETfglQORZ0zpDET4Zrk3igikrdHlWFoFJSRXICuHe+eya20PhEY= X-Mailru-Sender: 689FA8AB762F73937C9FA53A4753B3136411011B51C7B603D89DD98D10D0DA2D2592EED716FDABA7E49D44BB4BD9522A059A1ED8796F048DB274557F927329BE89D5A3BC2B10C37545BD1C3CC395C826B4A721A3011E896F X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit] x86/x64: Use scratch register for IR_TOBIT and IR_CONV u64.num. X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Sergey Kaplun via Tarantool-patches Reply-To: Sergey Kaplun Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Hi, Sergey! Thanks for the review! Fixed your comments and force-pushed branch. On 23.11.26, Sergey Bronnikov wrote: > Hi, Sergey, > > thanks for the patch! Please see my comments below. > > Sergey > > On 11/18/26 11:48, Sergey Kaplun wrote: > > From: Mike Pall > > > > Reported by aleksisch. Thanks to Sergey Kaplun. > > > > (cherry picked from commit 5585364753b52ac7de4695026fc28be2480c82bd) > > > > If `asm_tobit()` allocates a register for the `op1` in the TOBIT IR, its > > value is modified by adding the TOBIT bias (the second operand). Hence, > > the restoring value of the source IR is incorrect due to this > > modification. > > > > This patch uses a scratch register instead. The `IR_CONV` case is > > similar but is unobservable since the adding value `LJ_K64_M2P64` > > (-2^64) is overlapped in the uint64_t representation. > > > > Sergey Kaplun: > > * added the description for the problem > and a regression test, right? Yep, added, thanks! > > > > Part of tarantool/tarantool#13442 > > --- > > > > Branch: https://github.com/tarantool/luajit/tree/skaplun/lj-1536-tobit-regalloc > > Related issues: > > * https://github.com/LuaJIT/LuaJIT/issues/1536 > > * https://github.com/tarantool/tarantool/issues/13442 > > > > Side note: macOS (x86_64) CI is red due to runner problems. The metrics > > CI is red due to problems with configuration. > > > > src/lj_asm_x86.h | 7 ++-- > > .../lj-1536-tobit-regalloc.test.lua | 36 +++++++++++++++++++ > > 2 files changed, 38 insertions(+), 5 deletions(-) > > create mode 100644 test/tarantool-tests/lj-1536-tobit-regalloc.test.lua > > > > diff --git a/src/lj_asm_x86.h b/src/lj_asm_x86.h > > index 0e3a473c..8e2156eb 100644 > > --- a/src/lj_asm_x86.h > > +++ b/src/lj_asm_x86.h > > diff --git a/test/tarantool-tests/lj-1536-tobit-regalloc.test.lua b/test/tarantool-tests/lj-1536-tobit-regalloc.test.lua > > new file mode 100644 > > index 00000000..120fa1b0 > > --- /dev/null > > +++ b/test/tarantool-tests/lj-1536-tobit-regalloc.test.lua > > @@ -0,0 +1,36 @@ > > +local tap = require('tap') > > + > > +-- Test file to demonstrate incorrect register allocation for > > +-- `IR_TOBIT` on x86/x64. > > +-- See also: https://github.com/LuaJIT/LuaJIT/issues/1536. > > +local test = tap.test('lj-1536-tobit-regalloc'):skipcond({ > > + ['Test requires JIT enabled'] = not jit.status(), > > +}) > > + > > +test:plan(1) > > + > > +local tobit = bit.tobit > > + > > +jit.opt.start('hotloop=1') > > + > > +local res > > +local VALUE = 0x100 > Why exactly this value? No reason, added the comment: =================================================================== diff --git a/test/tarantool-tests/lj-1536-tobit-regalloc.test.lua b/test/tarantool-tests/lj-1536-tobit-regalloc.test.lua index 120fa1b0..8c304ac0 100644 --- a/test/tarantool-tests/lj-1536-tobit-regalloc.test.lua +++ b/test/tarantool-tests/lj-1536-tobit-regalloc.test.lua @@ -14,6 +14,7 @@ local tobit = bit.tobit jit.opt.start('hotloop=1') local res +-- Some value to be unchanged. local VALUE = 0x100 -- Use a table for the `noreg` of the tobit operand. local t = {k = VALUE} =================================================================== -- Best regards, Sergey Kaplun