diff --git a/core/alien/c-types/c-types.factor b/core/alien/c-types/c-types.factor index 405d679f4a..c553ca5cfb 100755 --- a/core/alien/c-types/c-types.factor +++ b/core/alien/c-types/c-types.factor @@ -151,8 +151,9 @@ M: byte-array byte-length length ; swap dup length memcpy ; : (define-nth) ( word type quot -- ) - >r heap-size [ rot * >fixnum ] swap prefix - r> append define-inline ; + [ + \ swap , [ heap-size , [ * >fixnum ] % ] [ % ] bi* + ] [ ] make define-inline ; : nth-word ( name vocab -- word ) >r "-nth" append r> create ; diff --git a/core/optimizer/math/math.factor b/core/optimizer/math/math.factor index c20cba99cb..2c4e33e183 100755 --- a/core/optimizer/math/math.factor +++ b/core/optimizer/math/math.factor @@ -406,7 +406,7 @@ most-negative-fixnum most-positive-fixnum [a,b] : convert-mod-to-and ( #call -- node ) dup - dup node-in-d second node-literal 1- + dup in-d>> second node-literal 1- [ nip bitand ] curry f splice-quot ; \ mod [ @@ -438,6 +438,19 @@ most-negative-fixnum most-positive-fixnum [a,b] } } define-optimizers +: convert-*-to-shift? ( #call -- ? ) + dup in-d>> second node-literal + dup integer? [ power-of-2? ] [ drop f ] if ; + +: convert-*-to-shift ( #call -- ? ) + dup dup in-d>> second node-literal log2 + [ nip fixnum-shift-fast ] curry + f splice-quot ; + +\ fixnum*fast { + { [ dup convert-*-to-shift? ] [ convert-*-to-shift ] } +} define-optimizers + { + - * / } [ { number number } "input-classes" set-word-prop ] each