diff --git a/basis/compiler/tree/propagation/propagation-tests.factor b/basis/compiler/tree/propagation/propagation-tests.factor index 4c6e8f55d7..1b24bc0c8f 100644 --- a/basis/compiler/tree/propagation/propagation-tests.factor +++ b/basis/compiler/tree/propagation/propagation-tests.factor @@ -819,3 +819,8 @@ M: tuple-with-read-only-slot clone ! Don't crash if bad literal inputs are passed to unsafe words [ f ] [ [ { } 1 fixnum+fast ] final-info first literal?>> ] unit-test + +! Converting /i to shift +[ t ] [ [ >fixnum dup 0 >= [ 16 /i ] when ] { /i fixnum/i fixnum/i-fast } inlined? ] unit-test +[ f ] [ [ >fixnum dup 0 >= [ 16 /i ] when ] { fixnum-shift-fast } inlined? ] unit-test +[ f ] [ [ >float dup 0 >= [ 16 /i ] when ] { /i float/f } inlined? ] unit-test diff --git a/basis/compiler/tree/propagation/transforms/transforms.factor b/basis/compiler/tree/propagation/transforms/transforms.factor index 9d0e5c8999..e08a21d4b9 100644 --- a/basis/compiler/tree/propagation/transforms/transforms.factor +++ b/basis/compiler/tree/propagation/transforms/transforms.factor @@ -80,6 +80,17 @@ IN: compiler.tree.propagation.transforms ] [ f ] if ] "custom-inlining" set-word-prop +{ /i fixnum/i fixnum/i-fast bignum/i } [ + [ + in-d>> first2 [ value-info ] bi@ { + [ drop class>> integer class<= ] + [ drop interval>> 0 [a,a] interval>= ] + [ nip literal>> integer? ] + [ nip literal>> power-of-2? ] + } 2&& [ [ log2 neg shift ] ] [ f ] if + ] "custom-inlining" set-word-prop +] each + ! Integrate this with generic arithmetic optimization instead? : both-inputs? ( #call class -- ? ) [ in-d>> first2 ] dip '[ value-info class>> _ class<= ] both? ;