Fix custom-inlining for mod and rem, which was converting these calls to bitand in some cases, even if the input was not known to be an integer. Fixes #243
parent
b4588629ab
commit
901ee2434c
|
@ -155,6 +155,8 @@ GENERIC: void-generic ( obj -- * )
|
|||
|
||||
[ 0 ] [ 5 [ 1 mod ] compile-call ] unit-test
|
||||
[ 0 ] [ 5 [ 1 rem ] compile-call ] unit-test
|
||||
[ 0.5 ] [ 5.5 [ 1 mod ] compile-call ] unit-test
|
||||
[ 0.5 ] [ 5.5 [ 1 rem ] compile-call ] unit-test
|
||||
|
||||
[ 5 ] [ 5 [ -1 bitand ] compile-call ] unit-test
|
||||
[ 0 ] [ 5 [ 0 bitand ] compile-call ] unit-test
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
! Copyright (C) 2008, 2010 Slava Pestov, Daniel Ehrenberg.
|
||||
! Copyright (C) 2008, 2011 Slava Pestov, Daniel Ehrenberg.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: alien.c-types kernel sequences words fry generic
|
||||
generic.single accessors classes.tuple classes classes.algebra
|
||||
|
@ -23,9 +23,11 @@ IN: compiler.tree.propagation.transforms
|
|||
] [ drop f ] if
|
||||
] "custom-inlining" set-word-prop
|
||||
|
||||
: rem-custom-inlining ( #call -- quot/f )
|
||||
second value-info literal>> dup integer?
|
||||
[ power-of-2? [ 1 - bitand ] f ? ] [ drop f ] if ;
|
||||
: rem-custom-inlining ( inputs -- quot/f )
|
||||
dup first value-info class integer class<= [
|
||||
second value-info literal>> dup integer?
|
||||
[ power-of-2? [ 1 - bitand ] f ? ] [ drop f ] if
|
||||
] [ drop f ] if ;
|
||||
|
||||
{
|
||||
mod-integer-integer
|
||||
|
|
Loading…
Reference in New Issue