comparison graal/GraalCompiler/src/com/sun/c1x/opt/PhiSimplifier.java @ 2695:785e9ecdcc69

Removed the instruction substitutor.
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Wed, 18 May 2011 15:03:45 +0200
parents 768d77a1c7af
children c1ce2a53d6c3
comparison
equal deleted inserted replaced
2694:773189811d10 2695:785e9ecdcc69
32 * @author Ben L. Titzer 32 * @author Ben L. Titzer
33 */ 33 */
34 public final class PhiSimplifier implements BlockClosure { 34 public final class PhiSimplifier implements BlockClosure {
35 35
36 final IR ir; 36 final IR ir;
37 final InstructionSubstituter subst;
38 37
39 public PhiSimplifier(IR ir) { 38 public PhiSimplifier(IR ir) {
40 this.ir = ir; 39 this.ir = ir;
41 this.subst = new InstructionSubstituter(ir);
42 ir.startBlock.iterateAnyOrder(this, false); 40 ir.startBlock.iterateAnyOrder(this, false);
43 subst.finish();
44 } 41 }
45 42
46 /** 43 /**
47 * This method is called for each block and processes any phi statements in the block. 44 * This method is called for each block and processes any phi statements in the block.
48 * @param block the block to apply the simplification to 45 * @param block the block to apply the simplification to
60 Value simplify(Value x) { 57 Value simplify(Value x) {
61 if (x == null || !(x instanceof Phi)) { 58 if (x == null || !(x instanceof Phi)) {
62 return x; 59 return x;
63 } 60 }
64 Phi phi = (Phi) x; 61 Phi phi = (Phi) x;
65 if (phi.hasSubst()) { 62 if (phi.checkFlag(Value.Flag.PhiCannotSimplify)) {
66 // already substituted, but the subst could be a phi itself, so simplify
67 return simplify(subst.getSubst(phi));
68 } else if (phi.checkFlag(Value.Flag.PhiCannotSimplify)) {
69 // already tried, cannot simplify this phi 63 // already tried, cannot simplify this phi
70 return phi; 64 return phi;
71 } else if (phi.checkFlag(Value.Flag.PhiVisited)) { 65 } else if (phi.checkFlag(Value.Flag.PhiVisited)) {
72 // break cycles in phis 66 // break cycles in phis
73 return phi; 67 return phi;
119 } 113 }
120 114
121 // successfully simplified the phi 115 // successfully simplified the phi
122 assert phiSubst != null : "illegal phi function"; 116 assert phiSubst != null : "illegal phi function";
123 phi.clearFlag(Value.Flag.PhiVisited); 117 phi.clearFlag(Value.Flag.PhiVisited);
124 subst.setSubst(phi, phiSubst);
125 return phiSubst; 118 return phiSubst;
126 } 119 }
127 } 120 }
128 } 121 }