]> gitweb.factorcode.org Git - factor.git/commitdiff
Fix custom-inlining for mod and rem, which was converting these calls to bitand in...
authorSlava Pestov <slava@factorcode.org>
Sun, 9 Oct 2011 20:51:27 +0000 (13:51 -0700)
committerSlava Pestov <slava@factorcode.org>
Sun, 9 Oct 2011 20:51:35 +0000 (13:51 -0700)
basis/compiler/tests/optimizer.factor
basis/compiler/tree/propagation/transforms/transforms.factor

index c3fd37c48a358de34913d3944cd472540409c54a..ac8651991920c6eafb736f0b20c42417a79af7ac 100644 (file)
@@ -155,6 +155,8 @@ GENERIC: void-generic ( obj -- * )
 
 [ 0 ] [ 5 [ 1 mod ] compile-call ] unit-test
 [ 0 ] [ 5 [ 1 rem ] compile-call ] unit-test
+[ 0.5 ] [ 5.5 [ 1 mod ] compile-call ] unit-test
+[ 0.5 ] [ 5.5 [ 1 rem ] compile-call ] unit-test
 
 [ 5 ] [ 5 [ -1 bitand ] compile-call ] unit-test
 [ 0 ] [ 5 [ 0 bitand ] compile-call ] unit-test
index 28de7abd4bfc93fc0d84f91f266b02732a707444..5c3d62477dbd4fc1e2d3ed5177f3e65dcb4faccf 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2008, 2010 Slava Pestov, Daniel Ehrenberg.
+! Copyright (C) 2008, 2011 Slava Pestov, Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: alien.c-types kernel sequences words fry generic
 generic.single accessors classes.tuple classes classes.algebra
@@ -23,9 +23,11 @@ IN: compiler.tree.propagation.transforms
     ] [ drop f ] if
 ] "custom-inlining" set-word-prop
 
-: rem-custom-inlining ( #call -- quot/f )
-    second value-info literal>> dup integer?
-    [ power-of-2? [ 1 - bitand ] f ? ] [ drop f ] if ;
+: rem-custom-inlining ( inputs -- quot/f )
+    dup first value-info class integer class<= [
+        second value-info literal>> dup integer?
+        [ power-of-2? [ 1 - bitand ] f ? ] [ drop f ] if
+    ] [ drop f ] if ;
 
 {
     mod-integer-integer