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 A66D36E460; Fri, 24 Jul 2026 13:02:48 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org A66D36E460 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1784887368; bh=FwjJpeLkK22J9vzTiHJnun7luhypBfj+lgFiuk0xh/o=; h=Date:To:Cc:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=MYEOD1ZdXYScXSfBXjfoQNe/EsLzMhvOLkKTeBs1Li1TvJkKXSBLuprAQGWHYmC+H ka+ARa+AY9T5oRIwgW98S79aP4EMWi7+Wk9QgaUtHfiOnYSeCuRsS9cGLyxi2bMTmj BjbNMBD8ePFHPybyuCerSab/GcCabx7rdAdLL1QI= Received: from send83.i.mail.ru (send83.i.mail.ru [89.221.237.178]) (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 6AEF46E460 for ; Fri, 24 Jul 2026 13:02:47 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 6AEF46E460 Received: by exim-smtp-6c76488b9f-8xmbz with esmtpa (envelope-from ) id 1wnCju-000000002eC-0j6W; Fri, 24 Jul 2026 13:02:46 +0300 Content-Type: multipart/alternative; boundary="------------ipMyLBMqux3NlumH1TWV5MYB" Message-ID: Date: Fri, 24 Jul 2026 13:02:44 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: Sergey Kaplun , Evgeniy Temirgaleev Cc: tarantool-patches@dev.tarantool.org References: <103733d5267298d59381cca0401fee35100ac63b.1784642965.git.skaplun@tarantool.org> In-Reply-To: <103733d5267298d59381cca0401fee35100ac63b.1784642965.git.skaplun@tarantool.org> X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD93ED3C6BF6FFA701FBF353A30C2EA510A8006DDB73367F39B182A05F538085040586F76288189B9193DE06ABAFEAF6705081090CC36E1303F7EC1506C8F585ED76EF1D6B1658FE618 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE71B5FCE2AF2D0EAB4EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637AC83A81C8FD4AD23D82A6BABE6F325AC2E85FA5F3EDFCBAA7353EFBB55337566DDF253B6BCADDB79CF6A38281F8BD2EF4E1C2B937D4CA51005038A9BC2904D3E389733CBF5DBD5E913377AFFFEAFD269176DF2183F8FC7C0A3E989B1926288338941B15DA834481FCF19DD082D7633A0EF3E4896CB9E6436389733CBF5DBD5E9D5E8D9A59859A8B636DA1BED736F9328CC7F00164DA146DA6F5DAA56C3B73B237318B6A418E8EAB86D1867E19FE14079C09775C1D3CA48CF3D321E7403792E342EB15956EA79C166A417C69337E82CC275ECD9A6C639B01B78DA827A17800CE7994FE22CF3C16DE0731C566533BA786AA5CC5B56E945C8DA X-C1DE0DAB: 0D63561A33F958A54860B59E876A06B35002B1117B3ED69603CD8E72BD7353431A1B8FE1FED62FE8823CB91A9FED034534781492E4B8EEAD3CCD70CEBBF18A22BDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0AD73CAD6646DEDE191716CD42B3DD1D34CAB70F9BE574AE9C625B6776AC983F447FC0B9F89525902EE6F57B2FD27647F25E66C117BDB76D659A4E568FFE7EBE7C53DBB5EA1D55361D51DEBC582CE5C3EADFBEB2677585BD0B00CFD0532A28624C7B8341EE9D5BE9A0AB93273F4E6A9CF212C3F41F6D614759593CC644FC66FB7B66536EB022892E5344C41F94D744909CE2512F26BEC029E55448553D2254B8D95CD72808BE417F3B9E0E7457915DAA85F X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXMZebaIdHP2ghjoIc/363UZI6Kf1ptIMVWmxowtcrDwUs7yLgqbRcOw= X-DA7885C5: 876B000A2F90385FF255D290C0D534F9E161F7CDA6CB1DC62CD5385A17EE8B792DAF50ED03B832045B1A4C17EAA7BC4BEF2421ABFA55128DAF83EF9164C44C7E X-Mailru-Sender: 689FA8AB762F7393520AF17B8A65FDE2C2D60995CD97E3B745F10D722E3ADB0E02835D39177DE5F0EF86D5F70DA33880E41E8EF7A07863ECB274557F927329BE2DDF8182D28ACDB545BD1C3CC395C826B4A721A3011E896F X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit 2/2] ARM: Make hard-float tobit conversions match JIT backend behavior. 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 Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" This is a multi-part message in MIME format. --------------ipMyLBMqux3NlumH1TWV5MYB Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hello, thanks for the patch! LGTM with a minor comment Sergey On 7/21/26 17:53, Sergey Kaplun wrote: > From: Mike Pall > > Reported by Peter Cawley. > > (cherry picked from commit 32a683d226a3b57adbfeabff17d1ae0f7676545d) > > On the arm architecture, the `tobit()` function incorrectly truncates s/arm/ARM/ > instead of rounding to the nearest integer. This leads to inconsistency > between various VMs (comparing to x86/x64, for example) and between the > arm VM and JIT. > > This patch uses an addition of 2^52 + 2^51 constant to the given > argument to convert it to the nearest integer value. After reading the > lowest 32 bits of the register, we get the expected result. > > The test is the same as for the previous commit. > > Sergey Kaplun: > * added the description for the problem > > Part of tarantool/tarantool#12880 > --- > src/vm_arm.dasc | 13 ++++++++++++- > 1 file changed, 12 insertions(+), 1 deletion(-) > > diff --git a/src/vm_arm.dasc b/src/vm_arm.dasc > index 7ed555f8..139f7fed 100644 > --- a/src/vm_arm.dasc > +++ b/src/vm_arm.dasc > @@ -1829,9 +1829,19 @@ static void build_subroutines(BuildCtx *ctx) > | > |//-- Bit library -------------------------------------------------------- > | > - |// FP number to bit conversion for soft-float. Clobbers r0-r3. > |->vm_tobit_fb: > | bhi ->fff_fallback > + |.if FPU > + |// FP number to bit conversion for hard-float. Clobbers r0, d0-d1. > + | vldr d1, >9 > + | vmov d0, CARG1, CARG2 > + | vadd.f64 d0, d0, d1 > + | vmov CARG1, s0 > + | bx lr > + |9: > + | .long 0, 0x43380000 // (double)(2^52 + 2^51). > + |.else > + |// FP number to bit conversion for soft-float. Clobbers r0-r3. > |->vm_tobit: > | lsl RB, CARG2, #1 > | adds RB, RB, #0x00200000 > @@ -1856,6 +1866,7 @@ static void build_subroutines(BuildCtx *ctx) > | orr CARG1, CARG4, CARG1, lsl RB > | rsblt CARG1, CARG1, #0 > | bx lr > + |.endif > | > |.macro .ffunc_bit, name > | .ffunc_1 bit_..name --------------ipMyLBMqux3NlumH1TWV5MYB Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit

Hello,

thanks for the patch! LGTM with a minor comment

Sergey

On 7/21/26 17:53, Sergey Kaplun wrote:
From: Mike Pall <mike>

Reported by Peter Cawley.

(cherry picked from commit 32a683d226a3b57adbfeabff17d1ae0f7676545d)

On the arm architecture, the `tobit()` function incorrectly truncates
s/arm/ARM/
instead of rounding to the nearest integer. This leads to inconsistency
between various VMs (comparing to x86/x64, for example) and between the
arm VM and JIT.

This patch uses an addition of 2^52 + 2^51 constant to the given
argument to convert it to the nearest integer value. After reading the
lowest 32 bits of the register, we get the expected result.

The test is the same as for the previous commit.

Sergey Kaplun:
* added the description for the problem

Part of tarantool/tarantool#12880
---
 src/vm_arm.dasc | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/vm_arm.dasc b/src/vm_arm.dasc
index 7ed555f8..139f7fed 100644
--- a/src/vm_arm.dasc
+++ b/src/vm_arm.dasc
@@ -1829,9 +1829,19 @@ static void build_subroutines(BuildCtx *ctx)
   |
   |//-- Bit library --------------------------------------------------------
   |
-  |// FP number to bit conversion for soft-float. Clobbers r0-r3.
   |->vm_tobit_fb:
   |  bhi ->fff_fallback
+  |.if FPU
+  |// FP number to bit conversion for hard-float. Clobbers r0, d0-d1.
+  |  vldr d1, >9
+  |  vmov d0, CARG1, CARG2
+  |  vadd.f64 d0, d0, d1
+  |  vmov CARG1, s0
+  |  bx lr
+  |9:
+  |  .long 0, 0x43380000		// (double)(2^52 + 2^51).
+  |.else
+  |// FP number to bit conversion for soft-float. Clobbers r0-r3.
   |->vm_tobit:
   |  lsl RB, CARG2, #1
   |  adds RB, RB, #0x00200000
@@ -1856,6 +1866,7 @@ static void build_subroutines(BuildCtx *ctx)
   |  orr CARG1, CARG4, CARG1, lsl RB
   |   rsblt CARG1, CARG1, #0
   |  bx lr
+  |.endif
   |
   |.macro .ffunc_bit, name
   |  .ffunc_1 bit_..name
--------------ipMyLBMqux3NlumH1TWV5MYB--