JIT repair for `(/ (most-negative-fixnum) -1)'

When I added JIT-inling of '/' for fixnums, I somehow forgot to
handle the special case that is already handled for `quotient'.
This commit is contained in:
Matthew Flatt 2013-07-21 09:59:08 -06:00
parent 22dbcaa77f
commit a0741c5ea7
3 changed files with 12 additions and 1 deletions

View File

@ -823,6 +823,8 @@
(test (expt 2 29) / (- (expt 2 30)) -2) (test (expt 2 29) / (- (expt 2 30)) -2)
(test -1/1073741824 / (- (expt 2 30))) (test -1/1073741824 / (- (expt 2 30)))
(test (expt 2 30) / (- (expt 2 30)) -1)
(test +inf.0 / 1.0 0.0) (test +inf.0 / 1.0 0.0)
(test -inf.0 / -1.0 0.0) (test -inf.0 / -1.0 0.0)
(test +inf.0 / -1.0 -0.0) (test +inf.0 / -1.0 -0.0)

View File

@ -499,6 +499,8 @@
(bin -4/3 '/ 4 -3) (bin -4/3 '/ 4 -3)
(bin -4/3 '/ -4 3) (bin -4/3 '/ -4 3)
(bin 4/3 '/ -4 -3) (bin 4/3 '/ -4 -3)
(bin (expt 2 30) '/ (- (expt 2 30)) -1)
(bin (expt 2 62) '/ (- (expt 2 62)) -1)
(bin-int 3 'quotient 10 3) (bin-int 3 'quotient 10 3)
(bin-int -3 'quotient 10 -3) (bin-int -3 'quotient 10 -3)
@ -508,6 +510,7 @@
(bin-exact 3 'fxquotient 10 3) (bin-exact 3 'fxquotient 10 3)
(bin-exact -3 'fxquotient 10 -3) (bin-exact -3 'fxquotient 10 -3)
(bin-exact (expt 2 30) 'quotient (- (expt 2 30)) -1) (bin-exact (expt 2 30) 'quotient (- (expt 2 30)) -1)
(bin-exact (expt 2 62) 'quotient (- (expt 2 62)) -1)
(bin-int 1 'remainder 10 3) (bin-int 1 'remainder 10 3)
(bin-int 1 'remainder 10 -3) (bin-int 1 'remainder 10 -3)

View File

@ -1616,13 +1616,19 @@ int scheme_generate_arith_for(mz_jit_state *jitter, Scheme_Object *rator, Scheme
jit_modr_l(JIT_R0, JIT_V1, JIT_R2); jit_modr_l(JIT_R0, JIT_V1, JIT_R2);
if (arith == ARITH_DIV) { if (arith == ARITH_DIV) {
GC_CAN_IGNORE jit_insn *refx; GC_CAN_IGNORE jit_insn *refx, *refz;
__START_INNER_TINY__(branch_short);
/* watch out for negation of most negative fixnum,
which is a positive number too big for a fixnum */
refz = jit_beqi_p(jit_forward(), JIT_R0, (void *)(((intptr_t)1 << ((8 * JIT_WORD_SIZE) - 2))));
__END_INNER_TINY__(branch_short);
if (reversed) if (reversed)
jit_mulr_l(JIT_R2, JIT_R0, JIT_R2); jit_mulr_l(JIT_R2, JIT_R0, JIT_R2);
else else
jit_mulr_l(JIT_V1, JIT_R0, JIT_V1); jit_mulr_l(JIT_V1, JIT_R0, JIT_V1);
__START_INNER_TINY__(branch_short); __START_INNER_TINY__(branch_short);
refx = jit_beqr_l(jit_forward(), JIT_R2, JIT_V1); refx = jit_beqr_l(jit_forward(), JIT_R2, JIT_V1);
mz_patch_branch(refz);
__END_INNER_TINY__(branch_short); __END_INNER_TINY__(branch_short);
/* restore R0 argument: */ /* restore R0 argument: */
if (reversed) { if (reversed) {