Re: Probably a bug in LuaJIT x86

  • From: Egor Skriptunoff <egor.skriptunoff@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Fri, 17 Aug 2018 08:16:46 +0300

On Thu, Aug 16, 2018 at 11:54 PM, Mike Pall wrote:

Egor Skriptunoff wrote:
Ok, I replaced ffi.typeof("uint32_t[?]") with ffi.typeof("int32_t[?]").
And 0xDEADBEEF with 0xEADBEEF.
Now all the datatypes are signed and all the constants are inside signed
int32 range.
The bug didn't disappear: a pair of unequal numbers is printed under
LuaJIT
x86.

But the addition is still done with a double intermediate numeric type.



Ok, how should I rewrite the statement
   arr[i] = arr[i-2] + ror(arr[i-1], 7)
so that LuaJIT would not create intermediate double datatype?
All I want is standard int32 arithmetics with usual wraparound addition.

It seems that with double intermediate results I have to always insert
"correctors" after every addition:
bit.tobit(x+y)  -- for int32_t-compatible result
(x+y)%2^32  -- for uint32_t-compatible result
Is there exist more fast and more compact way to perform int32 arithmetics
in LuaJIT?

Other related posts: