]> gitweb.factorcode.org Git - factor.git/commitdiff
compiler.cfg: Fixing test failures
authorSlava Pestov <slava@shill.local>
Fri, 24 Jul 2009 11:08:07 +0000 (06:08 -0500)
committerSlava Pestov <slava@shill.local>
Fri, 24 Jul 2009 11:08:07 +0000 (06:08 -0500)
basis/compiler/cfg/value-numbering/simplify/simplify.factor
basis/compiler/cfg/value-numbering/value-numbering-tests.factor
basis/compiler/cfg/value-numbering/value-numbering.factor
basis/compiler/cfg/write-barrier/write-barrier-tests.factor

index 3e1f6e393b708a820f0a1c20c5f6b0d5d00903f7..6bd84021b36189b811f3520506a8e47856c0cf2f 100644 (file)
@@ -120,12 +120,12 @@ M: binary-expr simplify*
 
 M: expr simplify* drop f ;
 
-: simplify ( expr -- simplified? vn )
+: simplify ( expr -- vn )
     dup simplify* {
-        { [ dup not ] [ drop expr>vn ] }
-        { [ dup expr? ] [ expr>vn nip ] }
-        { [ dup integer? ] [ nip ] }
-    } cond swap ;
+        { [ dup not ] [ drop expr>vn ] }
+        { [ dup expr? ] [ expr>vn nip ] }
+        { [ dup integer? ] [ nip ] }
+    } cond ;
 
-: number-values ( insn -- simplified? )
-    [ >expr simplify ] [ dst>> set-vn ] bi ;
+: number-values ( insn -- )
+    [ >expr simplify ] [ dst>> ] bi set-vn ;
index 9063947ae17af212d03856c73c143d8088b4b0b5..60d06fcde4d63406ec5269ec6f6b69f7c61663a0 100644 (file)
@@ -35,9 +35,9 @@ compiler.cfg assocs vectors arrays layouts namespaces ;
 [
     {
         T{ ##load-reference f V int-regs 0 0.0 }
-        T{ ##load-reference f V int-regs 1 0.0 }
+        T{ ##copy f V int-regs 1 V int-regs 0 }
         T{ ##replace f V int-regs 0 D 0 }
-        T{ ##replace f V int-regs 0 D 1 }
+        T{ ##replace f V int-regs 1 D 1 }
     }
 ] [
     {
@@ -51,9 +51,9 @@ compiler.cfg assocs vectors arrays layouts namespaces ;
 [
     {
         T{ ##load-reference f V int-regs 0 t }
-        T{ ##load-reference f V int-regs 1 t }
+        T{ ##copy f V int-regs 1 V int-regs 0 }
         T{ ##replace f V int-regs 0 D 0 }
-        T{ ##replace f V int-regs 0 D 1 }
+        T{ ##replace f V int-regs 1 D 1 }
     }
 ] [
     {
@@ -64,29 +64,14 @@ compiler.cfg assocs vectors arrays layouts namespaces ;
     } value-numbering-step
 ] unit-test
 
-! Copy propagation
-[
-    {
-        T{ ##peek f V int-regs 45 D 1 }
-        T{ ##copy f V int-regs 48 V int-regs 45 }
-        T{ ##compare-imm-branch f V int-regs 45 7 cc/= }
-    }
-] [
-    {
-        T{ ##peek f V int-regs 45 D 1 }
-        T{ ##copy f V int-regs 48 V int-regs 45 }
-        T{ ##compare-imm-branch f V int-regs 48 7 cc/= }
-    } value-numbering-step
-] unit-test
-
 ! Compare propagation
 [
     {
         T{ ##load-reference f V int-regs 1 + }
         T{ ##peek f V int-regs 2 D 0 }
         T{ ##compare f V int-regs 4 V int-regs 2 V int-regs 1 cc> }
-        T{ ##compare f V int-regs 6 V int-regs 2 V int-regs 1 cc> }
-        T{ ##replace f V int-regs 4 D 0 }
+        T{ ##copy f V int-regs 6 V int-regs 4 }
+        T{ ##replace f V int-regs 6 D 0 }
     }
 ] [
     {
@@ -612,8 +597,8 @@ compiler.cfg assocs vectors arrays layouts namespaces ;
         T{ ##peek f V int-regs 0 D 0 }
         T{ ##peek f V int-regs 1 D 1 }
         T{ ##load-immediate f V int-regs 2 0 }
-        T{ ##add-imm f V int-regs 3 V int-regs 0 0 }
-        T{ ##replace f V int-regs 0 D 0 }
+        T{ ##copy f V int-regs 3 V int-regs 0 }
+        T{ ##replace f V int-regs 3 D 0 }
     }
 ] [
     {
@@ -630,8 +615,8 @@ compiler.cfg assocs vectors arrays layouts namespaces ;
         T{ ##peek f V int-regs 0 D 0 }
         T{ ##peek f V int-regs 1 D 1 }
         T{ ##load-immediate f V int-regs 2 0 }
-        T{ ##add-imm f V int-regs 3 V int-regs 0 0 }
-        T{ ##replace f V int-regs 0 D 0 }
+        T{ ##copy f V int-regs 3 V int-regs 0 }
+        T{ ##replace f V int-regs 3 D 0 }
     }
 ] [
     {
@@ -648,8 +633,8 @@ compiler.cfg assocs vectors arrays layouts namespaces ;
         T{ ##peek f V int-regs 0 D 0 }
         T{ ##peek f V int-regs 1 D 1 }
         T{ ##load-immediate f V int-regs 2 0 }
-        T{ ##or-imm f V int-regs 3 V int-regs 0 0 }
-        T{ ##replace f V int-regs 0 D 0 }
+        T{ ##copy f V int-regs 3 V int-regs 0 }
+        T{ ##replace f V int-regs 3 D 0 }
     }
 ] [
     {
@@ -666,8 +651,8 @@ compiler.cfg assocs vectors arrays layouts namespaces ;
         T{ ##peek f V int-regs 0 D 0 }
         T{ ##peek f V int-regs 1 D 1 }
         T{ ##load-immediate f V int-regs 2 0 }
-        T{ ##xor-imm f V int-regs 3 V int-regs 0 0 }
-        T{ ##replace f V int-regs 0 D 0 }
+        T{ ##copy f V int-regs 3 V int-regs 0 }
+        T{ ##replace f V int-regs 3 D 0 }
     }
 ] [
     {
@@ -683,8 +668,8 @@ compiler.cfg assocs vectors arrays layouts namespaces ;
     {
         T{ ##peek f V int-regs 0 D 0 }
         T{ ##load-immediate f V int-regs 1 1 }
-        T{ ##shl-imm f V int-regs 2 V int-regs 0 0 }
-        T{ ##replace f V int-regs 0 D 0 }
+        T{ ##copy f V int-regs 2 V int-regs 0 }
+        T{ ##replace f V int-regs 2 D 0 }
     }
 ] [
     {
index 0688d81109ef3dee8481242ba9a8f2e3ebef4911..a249f71c023d7e7802f54aae35e59baea4a2e072 100644 (file)
@@ -12,8 +12,9 @@ compiler.cfg.value-numbering.rewrite ;
 IN: compiler.cfg.value-numbering
 
 ! Local value numbering. Predecessors must be recomputed after this
-: >copy ( insn -- ##copy )
-    dst>> dup vreg>vn vn>vreg \ ##copy new-insn ;
+: >copy ( insn -- insn/##copy )
+    dup dst>> dup vreg>vn vn>vreg
+    2dup eq? [ 2drop ] [ \ ##copy new-insn nip ] if ;
 
 : rewrite-loop ( insn -- insn' )
     dup rewrite [ rewrite-loop ] [ ] ?if ;
@@ -23,7 +24,7 @@ GENERIC: process-instruction ( insn -- insn' )
 M: ##flushable process-instruction
     dup rewrite
     [ process-instruction ]
-    [ dup number-values [ >copy ] when ] ?if ;
+    [ dup number-values >copy ] ?if ;
 
 M: insn process-instruction
     dup rewrite
index c1a667c00497b9012e22060b426f937d5bdba458..14197bc3f74830f5cd3f26911d822fe557262f1b 100644 (file)
@@ -1,42 +1,43 @@
 USING: compiler.cfg.write-barrier compiler.cfg.instructions
 compiler.cfg.registers compiler.cfg.debugger cpu.architecture
-arrays tools.test vectors compiler.cfg kernel accessors ;
+arrays tools.test vectors compiler.cfg kernel accessors
+compiler.cfg.utilities ;
 IN: compiler.cfg.write-barrier.tests
 
 : test-write-barrier ( insns -- insns )
-    write-barriers-step ;
+    <simple-block> dup write-barriers-step instructions>> ;
 
 [
-    {
+    V{
         T{ ##peek f V int-regs 4 D 0 f }
-        T{ ##copy f V int-regs 6 V int-regs 4 f }
         T{ ##allot f V int-regs 7 24 array V int-regs 8 f }
         T{ ##load-immediate f V int-regs 9 8 f }
         T{ ##set-slot-imm f V int-regs 9 V int-regs 7 1 3 f }
-        T{ ##set-slot-imm f V int-regs 6 V int-regs 7 2 3 f }
+        T{ ##set-slot-imm f V int-regs 4 V int-regs 7 2 3 f }
         T{ ##replace f V int-regs 7 D 0 f }
+        T{ ##branch }
     }
 ] [
     {
         T{ ##peek f V int-regs 4 D 0 }
-        T{ ##copy f V int-regs 6 V int-regs 4 }
         T{ ##allot f V int-regs 7 24 array V int-regs 8 }
         T{ ##load-immediate f V int-regs 9 8 }
         T{ ##set-slot-imm f V int-regs 9 V int-regs 7 1 3 }
         T{ ##write-barrier f V int-regs 7 V int-regs 10 V int-regs 11 }
-        T{ ##set-slot-imm f V int-regs 6 V int-regs 7 2 3 }
+        T{ ##set-slot-imm f V int-regs 4 V int-regs 7 2 3 }
         T{ ##write-barrier f V int-regs 7 V int-regs 12 V int-regs 13 }
         T{ ##replace f V int-regs 7 D 0 }
     } test-write-barrier
 ] unit-test
 
 [
-    {
+    V{
         T{ ##load-immediate f V int-regs 4 24 }
         T{ ##peek f V int-regs 5 D -1 }
         T{ ##peek f V int-regs 6 D -2 }
         T{ ##set-slot-imm f V int-regs 5 V int-regs 6 3 2 }
         T{ ##write-barrier f V int-regs 6 V int-regs 7 V int-regs 8 }
+        T{ ##branch }
     }
 ] [
     {
@@ -49,28 +50,23 @@ IN: compiler.cfg.write-barrier.tests
 ] unit-test
 
 [
-    {
+    V{
         T{ ##peek f V int-regs 19 D -3 }
         T{ ##peek f V int-regs 22 D -2 }
-        T{ ##copy f V int-regs 23 V int-regs 19 }
-        T{ ##set-slot-imm f V int-regs 22 V int-regs 23 3 2 }
-        T{ ##write-barrier f V int-regs 23 V int-regs 24 V int-regs 25 }
-        T{ ##copy f V int-regs 26 V int-regs 19 }
+        T{ ##set-slot-imm f V int-regs 22 V int-regs 19 3 2 }
+        T{ ##write-barrier f V int-regs 19 V int-regs 24 V int-regs 25 }
         T{ ##peek f V int-regs 28 D -1 }
-        T{ ##copy f V int-regs 29 V int-regs 19 }
-        T{ ##set-slot-imm f V int-regs 28 V int-regs 29 4 2 }
+        T{ ##set-slot-imm f V int-regs 28 V int-regs 19 4 2 }
+        T{ ##branch }
     }
 ] [
     {
         T{ ##peek f V int-regs 19 D -3 }
         T{ ##peek f V int-regs 22 D -2 }
-        T{ ##copy f V int-regs 23 V int-regs 19 }
-        T{ ##set-slot-imm f V int-regs 22 V int-regs 23 3 2 }
-        T{ ##write-barrier f V int-regs 23 V int-regs 24 V int-regs 25 }
-        T{ ##copy f V int-regs 26 V int-regs 19 }
+        T{ ##set-slot-imm f V int-regs 22 V int-regs 19 3 2 }
+        T{ ##write-barrier f V int-regs 19 V int-regs 24 V int-regs 25 }
         T{ ##peek f V int-regs 28 D -1 }
-        T{ ##copy f V int-regs 29 V int-regs 19 }
-        T{ ##set-slot-imm f V int-regs 28 V int-regs 29 4 2 }
-        T{ ##write-barrier f V int-regs 29 V int-regs 30 V int-regs 3 }
+        T{ ##set-slot-imm f V int-regs 28 V int-regs 19 4 2 }
+        T{ ##write-barrier f V int-regs 19 V int-regs 30 V int-regs 3 }
     } test-write-barrier
 ] unit-test