1 ! Copyright (C) 2009, 2011 Slava Pestov.
2 ! See https://factorcode.org/license.txt for BSD license.
3 USING: accessors assocs compiler.cfg.def-use compiler.cfg.dominance
4 compiler.cfg.instructions compiler.cfg.liveness
5 compiler.cfg.parallel-copy compiler.cfg.rpo compiler.cfg.ssa.cssa
6 compiler.cfg.ssa.destruction.coalescing compiler.cfg.ssa.destruction.leaders
7 compiler.cfg.ssa.interference.live-ranges compiler.cfg.utilities
8 kernel make sequences namespaces ;
9 IN: compiler.cfg.ssa.destruction
13 GENERIC: cleanup-insn ( insn -- )
15 : useful-copy? ( insn -- ? )
16 [ dst>> ] [ src>> ] bi leaders = not ; inline
18 M: ##copy cleanup-insn
19 dup useful-copy? [ , ] [ drop ] if ;
21 M: ##parallel-copy cleanup-insn
22 values>> [ leaders ] assoc-map [ first2 = ] reject
25 M: ##tagged>integer cleanup-insn
26 dup useful-copy? [ , ] [ drop ] if ;
28 M: ##phi cleanup-insn drop ;
30 M: insn cleanup-insn , ;
32 : cleanup-cfg ( cfg -- )
33 [ [ [ cleanup-insn ] each ] V{ } make ] simple-optimization ;
37 : destruct-ssa ( cfg -- )