From eb31589092b7c01eb88667b1d59885ecfcc050fd Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Thu, 8 Oct 2009 00:59:15 -0500 Subject: [PATCH] Adding identity to propagation to remove some redundant bitands --- .../tree/propagation/propagation-tests.factor | 3 +++ .../propagation/transforms/transforms.factor | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/basis/compiler/tree/propagation/propagation-tests.factor b/basis/compiler/tree/propagation/propagation-tests.factor index 92964654bf..c1b6691542 100644 --- a/basis/compiler/tree/propagation/propagation-tests.factor +++ b/basis/compiler/tree/propagation/propagation-tests.factor @@ -899,3 +899,6 @@ M: tuple-with-read-only-slot clone ! We want this to inline [ t ] [ [ void* ] { } inlined? ] unit-test [ V{ void*-array } ] [ [ void* ] 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 diff --git a/basis/compiler/tree/propagation/transforms/transforms.factor b/basis/compiler/tree/propagation/transforms/transforms.factor index 8aa6a821d8..08ac306248 100644 --- a/basis/compiler/tree/propagation/transforms/transforms.factor +++ b/basis/compiler/tree/propagation/transforms/transforms.factor @@ -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 ] ]