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 53BDB6F843; Tue, 24 Nov 2026 13:21:11 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 53BDB6F843 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1795515671; bh=AtsGk3ffTd22M21Akim3isaM4PMRvV8/udRJ+oKy3rg=; 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=XKhur5RrkIPOXjA+0ZZlWBotYPGpL1Fu0bYvvYVQSiQyefCMlT+iparXu9gJ6bPCD 9JzYB2DEN9JlqNwM7ijt+umqlq6SMXv7eciQ/2ATZWQncGrUJFWQSAZaZgRcBEXm0m k2CRCFAAYhO2r6Alx4PPo2XutB77HJUQk9LBG4wk= Received: from send242.i.mail.ru (send242.i.mail.ru [95.163.59.81]) (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 DD9CE6F843 for ; Tue, 24 Nov 2026 13:21:09 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org DD9CE6F843 Received: by exim-smtp-canary-30-7cf57c478c-fcjgf with esmtpa (envelope-from ) id 1xVne8-00000000D7M-0tpy; Tue, 24 Nov 2026 13:21:08 +0300 Message-ID: <8deeb918-fe94-4146-ba31-10f0d14e4594@tarantool.org> Date: Tue, 24 Nov 2026 13:21:07 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: Sergey Kaplun References: <20261118084808.3591198-1-skaplun@tarantool.org> <79a76da9-a60f-41f6-b3bc-dcae4faa1ed1@tarantool.org> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD9DFC18640EC982097122D20FA8431945B6BA03077C98BB699182A05F5380850407D77DC34A3DBCFC43DE06ABAFEAF670508E4C561728892C57A2B66AF6AE06C515E5D4A160AC272F4 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE743AE26858062A689EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637AC83A81C8FD4AD23D82A6BABE6F325AC2E85FA5F3EDFCBAA7353EFBB5533756603DA5D6BE41EFC0DF9CBB8DD0A1A3656EAEA201A9373B9C190A1DB9CA33B0ABD389733CBF5DBD5E9D5E8D9A59859A8B625DC386152A6764ACC7F00164DA146DA6F5DAA56C3B73B237318B6A418E8EAB86D1867E19FE14079C09775C1D3CA48CF3D321E7403792E342EB15956EA79C166A417C69337E82CC275ECD9A6C639B01B78DA827A17800CE70BB89B22BF4660DC731C566533BA786AA5CC5B56E945C8DA X-C1DE0DAB: 0D63561A33F958A55DA23602FF1B0CFB5002B1117B3ED6962A14669F7189ED24715D9AB585B0EB04823CB91A9FED034534781492E4B8EEADD0953842B444AAC3BDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0AD73CAD6646DEDE1918E10F71CB4DF9F96AB70F9BE574AE9C625B6776AC983F447FC0B9F89525902EE6F57B2FD27647F25E66C117BDB76D659DFF33B6D4D4C929F7AB5A7F46A1B6412C0BC4E653899AD5AE315AF51143070EA6B17EC58CF9D5F45B8341EE9D5BE9A0AD60F648C48339AD2A72C22E7A85E7D85DD070189029D82CF6536EB022892E5344C41F94D744909CE2512F26BEC029E55448553D2254B8D95CD72808BE417F3B9E0E7457915DAA85F X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXOcIETfglQORZ0zpDET4Zrk3igikrdHlWAgYquWX4oaeAP+qXqN/L60= X-Mailru-Sender: 689FA8AB762F73937C9FA53A4753B3130AED7A29476138F2401CF68178396F4B2CABC1B42BADE231EF86D5F70DA33880E41E8EF7A07863ECB274557F927329BE2DDF8182D28ACDB545BD1C3CC395C826B4A721A3011E896F 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 Bronnikov via Tarantool-patches Reply-To: Sergey Bronnikov Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Hi, Sergey, thanks for the fixes! LGTM Sergey On 11/24/26 11:00, Sergey Kaplun wrote: > 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} > =================================================================== > > >