compiler.tree.propagation: bitand custom inlining was wrong if the second input was a bignum

db4
Slava Pestov 2009-08-20 03:47:07 -05:00
parent b4803b3191
commit f01f7ad6eb
2 changed files with 19 additions and 4 deletions

View File

@ -82,6 +82,8 @@ IN: compiler.tree.propagation.tests
[ bignum ] [ [ { bignum bignum } declare bitxor ] final-math-class ] unit-test [ bignum ] [ [ { bignum bignum } declare bitxor ] final-math-class ] unit-test
[ bignum ] [ [ { integer } declare 123 >bignum bitand ] final-math-class ] unit-test
[ float ] [ [ { float float } declare mod ] final-math-class ] unit-test [ float ] [ [ { float float } declare mod ] final-math-class ] unit-test
[ V{ fixnum } ] [ [ 255 bitand ] final-classes ] unit-test [ V{ fixnum } ] [ [ 255 bitand ] final-classes ] unit-test

View File

@ -38,6 +38,12 @@ IN: compiler.tree.propagation.transforms
in-d>> rem-custom-inlining in-d>> rem-custom-inlining
] "custom-inlining" set-word-prop ] "custom-inlining" set-word-prop
: positive-fixnum? ( obj -- ? )
{ [ fixnum? ] [ 0 >= ] } 1&& ;
: simplify-bitand? ( value -- ? )
value-info literal>> positive-fixnum? ;
{ {
bitand-integer-integer bitand-integer-integer
bitand-integer-fixnum bitand-integer-fixnum
@ -45,10 +51,17 @@ IN: compiler.tree.propagation.transforms
bitand bitand
} [ } [
[ [
in-d>> second value-info >literal< [ {
0 most-positive-fixnum between? {
[ [ >fixnum ] bi@ fixnum-bitand ] f ? [ dup in-d>> first simplify-bitand? ]
] when [ drop [ >fixnum fixnum-bitand ] ]
}
{
[ dup in-d>> second simplify-bitand? ]
[ drop [ [ >fixnum ] dip fixnum-bitand ] ]
}
[ drop f ]
} cond
] "custom-inlining" set-word-prop ] "custom-inlining" set-word-prop
] each ] each