]> gitweb.factorcode.org Git - factor.git/commitdiff
compiler.cfg.ssa.destruction: the natural-sort was malplaced, only sort
authorBjörn Lindqvist <bjourne@gmail.com>
Mon, 15 Jun 2015 06:10:05 +0000 (08:10 +0200)
committerBjörn Lindqvist <bjourne@gmail.com>
Mon, 15 Jun 2015 10:28:30 +0000 (12:28 +0200)
inputs from ##phi, should fix remainder of #1345

basis/compiler/cfg/ssa/destruction/destruction-docs.factor
basis/compiler/cfg/ssa/destruction/destruction-tests.factor
basis/compiler/cfg/ssa/destruction/destruction.factor

index 8585c56d104de699f2c045b65e3a11f6542712d7..2fea4ed3ca536343c1bd79944b2779921dd5b4b0 100644 (file)
@@ -29,7 +29,7 @@ HELP: try-eliminate-copy
 
 HELP: try-eliminate-copies
 { $values { "pairs" "a sequence of vreg pairs" } { "must?" boolean } }
-{ $description "Tries to eliminate the vreg copies in the " { $link sequence } " 'pairs'. If 'must?' is " { $link t } " then a " { $link vregs-shouldn't-interfere } " error is thrown if any of the vregs interfere. To ensure deterministic " { $link leader-map } " data, the pairs are sorted." }
+{ $description "Tries to eliminate the vreg copies in the " { $link sequence } " 'pairs'. If 'must?' is " { $link t } " then a " { $link vregs-shouldn't-interfere } " error is thrown if any of the vregs interfere." }
 { $see-also try-eliminate-copy } ;
 
 ARTICLE: "compiler.cfg.ssa.destruction" "SSA Destruction"
@@ -41,6 +41,12 @@ ARTICLE: "compiler.cfg.ssa.destruction" "SSA Destruction"
 }
 $nl
 "Main entry point:"
-{ $subsections destruct-ssa } ;
+{ $subsections destruct-ssa }
+"Vreg copy elimination:"
+{ $subsections
+  perform-coalescing
+  try-eliminate-copies
+  try-eliminate-copy
+} ;
 
 ABOUT: "compiler.cfg.ssa.destruction"
index 217a1b7f916f685281486a7b6657468b0e7eac52..661d567d4152a06b1d9f6ac5aa19fc3f7f5f29fb 100644 (file)
@@ -2,8 +2,9 @@ USING: alien.syntax assocs compiler.cfg.def-use
 compiler.cfg.instructions compiler.cfg.registers
 compiler.cfg.ssa.destruction compiler.cfg.ssa.destruction.leaders
 compiler.cfg.ssa.destruction.private compiler.cfg.utilities
-cpu.architecture cpu.x86.assembler.operands grouping kernel make namespaces
-random sequences tools.test ;
+cpu.architecture cpu.x86.assembler.operands grouping kernel make math
+math.functions math.order math.ranges namespaces random sequences
+tools.test ;
 QUALIFIED: sets
 IN: compiler.cfg.ssa.destruction.tests
 
@@ -99,3 +100,10 @@ IN: compiler.cfg.ssa.destruction.tests
         2286 leader
     ] replicate all-equal?
 ] unit-test
+
+! Test is just to ensure the my-euler word compiles. See #1345
+: my-euler-step ( min m n -- min' )
+    dup sqrt 1 mod [ - min ] [ 2drop ] if ; inline
+
+: my-euler ( -- answer )
+    33 2500 [1,b] [ dup [1,b] [ my-euler-step ] with each ] each ;
index 73e4d125943d653339fc9d65b7d67ac491a6e887..8a0d41a9b2822f49f88cd9a13bbfa2ccc9ed0fd2 100644 (file)
@@ -74,7 +74,7 @@ ERROR: vregs-shouldn't-interfere vreg1 vreg2 ;
     ] if ;
 
 : try-eliminate-copies ( pairs must? -- )
-    [ natural-sort ] dip '[ first2 _ try-eliminate-copy ] each ;
+    '[ first2 _ try-eliminate-copy ] each ;
 
 M: ##tagged>integer prepare-insn
     [ dst>> ] [ src>> ] bi t try-eliminate-copy ;
@@ -83,16 +83,14 @@ M: ##tagged>integer prepare-insn
     [ 2array ] with map ;
 
 M: ##phi prepare-insn
-    [ dst>> ] [ inputs>> values ] bi zip-scalar t try-eliminate-copies ;
+    [ dst>> ] [ inputs>> values ] bi zip-scalar
+    natural-sort t try-eliminate-copies ;
 
 : prepare-coalescing ( cfg -- )
     init-coalescing [ [ prepare-insn ] each ] simple-analysis ;
 
-: process-copies ( copies -- )
-    >alist f try-eliminate-copies ;
-
 : perform-coalescing ( cfg -- )
-    prepare-coalescing copies get process-copies ;
+    prepare-coalescing copies get f try-eliminate-copies ;
 
 GENERIC: cleanup-insn ( insn -- )