Mercurial > hg > graal-compiler
diff graal/GraalCompiler/src/com/sun/c1x/gen/PhiSimplifier.java @ 2821:015be60afcf3
removed flags from Value class
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Mon, 30 May 2011 17:05:06 +0200 |
parents | 189ffb7d1d84 |
children | 7f14e6b48a9c |
line wrap: on
line diff
--- a/graal/GraalCompiler/src/com/sun/c1x/gen/PhiSimplifier.java Mon May 30 16:24:22 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/gen/PhiSimplifier.java Mon May 30 17:05:06 2011 +0200 @@ -31,8 +31,15 @@ */ public final class PhiSimplifier { + private NodeBitMap visited; + private NodeBitMap cannotSimplify; + public PhiSimplifier(IR ir) { - for (Node n : ir.compilation.graph.getNodes()) { + Graph graph = ir.compilation.graph; + visited = graph.createNodeBitMap(); + cannotSimplify = graph.createNodeBitMap(); + + for (Node n : graph.getNodes()) { if (n instanceof Phi) { simplify((Phi) n); } @@ -45,41 +52,41 @@ } Phi phi = (Phi) x; - if (phi.valueCount() == 1 && !phi.checkFlag(Value.Flag.PhiCannotSimplify)) { + if (phi.valueCount() == 1 && !cannotSimplify.isMarked(phi)) { return (Value) phi.replace(phi.valueAt(0)); } - if (phi.checkFlag(Value.Flag.PhiCannotSimplify)) { + if (cannotSimplify.isMarked(phi)) { // already tried, cannot simplify this phi return phi; - } else if (phi.checkFlag(Value.Flag.PhiVisited)) { + } else if (visited.isMarked(phi)) { // break cycles in phis return phi; - } else if (phi.isIllegal()) { + } else if (phi.isDead()) { // don't bother with illegals return phi; } else { // attempt to simplify the phi by recursively simplifying its operands - phi.setFlag(Value.Flag.PhiVisited); + visited.mark(phi); Value phiSubst = null; int max = phi.valueCount(); boolean cannotSimplify = false; for (int i = 0; i < max; i++) { Value oldInstr = phi.valueAt(i); - if (oldInstr == null || oldInstr.isIllegal() || oldInstr.isDeadPhi()) { + if (oldInstr == null || (oldInstr instanceof Phi && ((Phi) oldInstr).isDead())) { // if one operand is illegal, make the entire phi illegal phi.makeDead(); - phi.clearFlag(Value.Flag.PhiVisited); + visited.clear(phi); return phi; } Value newInstr = simplify(oldInstr); - if (newInstr == null || newInstr.isIllegal() || newInstr.isDeadPhi()) { + if (newInstr == null || (newInstr instanceof Phi && ((Phi) newInstr).isDead())) { // if the subst instruction is illegal, make the entire phi illegal phi.makeDead(); - phi.clearFlag(Value.Flag.PhiVisited); + visited.clear(phi); return phi; } @@ -97,17 +104,16 @@ } } if (cannotSimplify) { - phi.setFlag(Value.Flag.PhiCannotSimplify); - phi.clearFlag(Value.Flag.PhiVisited); + this.cannotSimplify.mark(phi); + visited.clear(phi); return phi; } // successfully simplified the phi assert phiSubst != null : "illegal phi function"; - phi.clearFlag(Value.Flag.PhiVisited); + visited.clear(phi); phi.replace(phiSubst); -// System.out.printf("replaced phi with %d inputs\n", max); return phiSubst; }