Adding identity to propagation to remove some redundant bitands

db4
Daniel Ehrenberg 2009-10-08 00:59:15 -05:00
parent 3179dacb3e
commit eb31589092
2 changed files with 19 additions and 0 deletions

View File

@ -899,3 +899,6 @@ M: tuple-with-read-only-slot clone
! We want this to inline
[ t ] [ [ void* <c-direct-array> ] { <c-direct-array> } inlined? ] unit-test
[ V{ void*-array } ] [ [ void* <c-direct-array> ] final-classes ] unit-test
[ t ] [ [ alien-unsigned-1 255 bitand ] { bitand fixnum-bitand } inlined? ] unit-test
[ t ] [ [ alien-unsigned-1 255 swap bitand ] { bitand fixnum-bitand } inlined? ] unit-test

View File

@ -45,6 +45,14 @@ IN: compiler.tree.propagation.transforms
: simplify-bitand? ( value -- ? )
value-info literal>> positive-fixnum? ;
: redundant-bitand? ( var 111... -- ? )
[ value-info ] bi@ { [
nip literal>>
{ [ positive-fixnum? ] [ dup 1 + bitand zero? ] } 1&&
] [
[ interval>> ] [ literal>> ] bi* 0 swap [a,b] interval-subset?
] } 2&& ;
{
bitand-integer-integer
bitand-integer-fixnum
@ -53,6 +61,14 @@ IN: compiler.tree.propagation.transforms
} [
[
{
{
[ dup in-d>> first2 redundant-bitand? ]
[ drop [ drop ] ]
}
{
[ dup in-d>> first2 swap redundant-bitand? ]
[ drop [ nip ] ]
}
{
[ dup in-d>> first simplify-bitand? ]
[ drop [ >fixnum fixnum-bitand ] ]