Skip to content

Commit

Permalink
Fix divide by -1.
Browse files Browse the repository at this point in the history
This problem affects all platforms. It was introduced by commit
ccae333 (Load SIMD constants with IR_FLOAD
from GG_State)

The error is that lj_ir_ksimd is used to construct the constant in op2 of
IR_NEG, but this function actually generates an IR_FLOAD of the constant
instead. In doing so, it overwrites fins (ie J->fold.ins). The fix is to
directly reference the required constant in simplify_nummuldiv_k.
  • Loading branch information
Charles Baylis committed Sep 1, 2016
1 parent 263a49a commit ba65697
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/lj_opt_fold.c
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ LJFOLDF(simplify_nummuldiv_k)
return LEFTFOLD;
} else if (n == -1.0) { /* x o -1 ==> -x */
fins->o = IR_NEG;
fins->op2 = (IRRef1)lj_ir_ksimd(J, LJ_KSIMD_NEG);
fins->op2 = lj_ir_k64(J, IR_KNUM, LJ_KSIMD(J, LJ_KSIMD_NEG)->u64);
return RETRYFOLD;
} else if (fins->o == IR_MUL && n == 2.0) { /* x * 2 ==> x + x */
fins->o = IR_ADD;
Expand Down
8 changes: 4 additions & 4 deletions test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ LUAJIT?=luajit
LUA_FLAGS?=-jdump=+rsXa
# Define tests which should be skipped for some reasons.
SKIPPED_LUA_TEST=fpm_cos addov
# mul and div on x86 fail due to issue with XCFLAGS="-DLUAJIT_ENABLE_GC64"
SKIPPED_LUA_TEST_x86_64=mul div
SKIPPED_LUA_TEST_i686=mul div
# mul on x86 fail due to issue with XCFLAGS="-DLUAJIT_ENABLE_GC64"
SKIPPED_LUA_TEST_x86_64=mul
SKIPPED_LUA_TEST_i686=mul
# Below features have not been implemented on aarch64.
SKIPPED_LUA_TEST_aarch64=div call_vararg \
SKIPPED_LUA_TEST_aarch64=call_vararg \
snew \
vload xstore_addvalue fstore xload_int \
abs atan2 ldexp max min pow \
Expand Down

0 comments on commit ba65697

Please sign in to comment.