compiler.tree.propagation: convert /i of a positive integer by a power of two into a shift
parent
86a848bae6
commit
dd661edf46
|
@ -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
|
||||
|
|
|
@ -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? ;
|
||||
|
|
Loading…
Reference in New Issue