Mercurial > hg > graal-compiler
changeset 15876:8df3b6d4a035
Merge.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Tue, 13 May 2014 02:31:41 +0200 |
parents | 2d5f9c7379c1 (diff) d556971b409c (current diff) |
children | f55153a2ca55 |
files | |
diffstat | 1 files changed, 46 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/IfNode.java Mon May 12 23:27:28 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/IfNode.java Tue May 13 02:31:41 2014 +0200 @@ -27,6 +27,7 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.api.meta.JavaTypeProfile.ProfiledType; import com.oracle.graal.api.meta.ProfilingInfo.TriState; +import com.oracle.graal.compiler.common.*; import com.oracle.graal.compiler.common.calc.*; import com.oracle.graal.compiler.common.type.*; import com.oracle.graal.debug.*; @@ -599,6 +600,18 @@ connectEnds(falseEnds, phiValues, oldFalseSuccessor, merge, tool); connectEnds(trueEnds, phiValues, oldTrueSuccessor, merge, tool); + if (this.trueSuccessorProbability == 0.0) { + for (AbstractEndNode endNode : trueEnds) { + propagateZeroProbability(endNode); + } + } + + if (this.trueSuccessorProbability == 1.0) { + for (AbstractEndNode endNode : falseEnds) { + propagateZeroProbability(endNode); + } + } + /* * Remove obsolete ends only after processing all ends, otherwise oldTrueSuccessor or * oldFalseSuccessor might have been removed if it is a LoopExitNode. @@ -620,6 +633,39 @@ return true; } + private void propagateZeroProbability(FixedNode startNode) { + Node prev = null; + for (FixedNode node : GraphUtil.predecessorIterable(startNode)) { + if (node instanceof IfNode) { + IfNode ifNode = (IfNode) node; + if (ifNode.trueSuccessor() == prev) { + if (ifNode.trueSuccessorProbability == 0.0) { + return; + } else if (ifNode.trueSuccessorProbability == 1.0) { + propagateZeroProbability((FixedNode) ifNode.predecessor()); + } else { + ifNode.setTrueSuccessorProbability(0.0); + } + } else if (ifNode.falseSuccessor() == prev) { + if (ifNode.trueSuccessorProbability == 1.0) { + return; + } else if (ifNode.trueSuccessorProbability == 0.0) { + propagateZeroProbability((FixedNode) ifNode.predecessor()); + } else { + ifNode.setTrueSuccessorProbability(1.0); + } + } else { + throw new GraalInternalError("Illegal state"); + } + } else if (node instanceof MergeNode) { + for (AbstractEndNode endNode : ((MergeNode) node).cfgPredecessors()) { + propagateZeroProbability(endNode); + } + } + prev = node; + } + } + private static boolean checkFrameState(FixedNode start) { FixedNode node = start; while (true) {