From c5ec490f39b4d24545f2470c923ea8efe0c65330 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Lindqvist?= Date: Mon, 15 Jun 2015 08:10:05 +0200 Subject: [PATCH] compiler.cfg.ssa.destruction: the natural-sort was malplaced, only sort inputs from ##phi, should fix remainder of #1345 --- .../cfg/ssa/destruction/destruction-docs.factor | 10 ++++++++-- .../cfg/ssa/destruction/destruction-tests.factor | 12 ++++++++++-- .../compiler/cfg/ssa/destruction/destruction.factor | 10 ++++------ 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/basis/compiler/cfg/ssa/destruction/destruction-docs.factor b/basis/compiler/cfg/ssa/destruction/destruction-docs.factor index 8585c56d10..2fea4ed3ca 100644 --- a/basis/compiler/cfg/ssa/destruction/destruction-docs.factor +++ b/basis/compiler/cfg/ssa/destruction/destruction-docs.factor @@ -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" diff --git a/basis/compiler/cfg/ssa/destruction/destruction-tests.factor b/basis/compiler/cfg/ssa/destruction/destruction-tests.factor index 217a1b7f91..661d567d41 100644 --- a/basis/compiler/cfg/ssa/destruction/destruction-tests.factor +++ b/basis/compiler/cfg/ssa/destruction/destruction-tests.factor @@ -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 ; diff --git a/basis/compiler/cfg/ssa/destruction/destruction.factor b/basis/compiler/cfg/ssa/destruction/destruction.factor index 73e4d12594..8a0d41a9b2 100644 --- a/basis/compiler/cfg/ssa/destruction/destruction.factor +++ b/basis/compiler/cfg/ssa/destruction/destruction.factor @@ -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 -- )