Mercurial > hg > graal-compiler
changeset 15880:a43ff5d18350
Merge.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Tue, 13 May 2014 19:19:27 +0200 |
parents | b963148055d6 (diff) 25ccd455f751 (current diff) |
children | a6eeb3750238 |
files | |
diffstat | 1 files changed, 49 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/IfNode.java Tue May 13 16:51:41 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/IfNode.java Tue May 13 19:19:27 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,42 @@ 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) { + continue; + } else { + ifNode.setTrueSuccessorProbability(0.0); + return; + } + } else if (ifNode.falseSuccessor() == prev) { + if (ifNode.trueSuccessorProbability == 1.0) { + return; + } else if (ifNode.trueSuccessorProbability == 0.0) { + continue; + } else { + ifNode.setTrueSuccessorProbability(1.0); + return; + } + } else { + throw new GraalInternalError("Illegal state"); + } + } else if (node instanceof MergeNode && !(node instanceof LoopBeginNode)) { + for (AbstractEndNode endNode : ((MergeNode) node).cfgPredecessors()) { + propagateZeroProbability(endNode); + } + return; + } + prev = node; + } + } + private static boolean checkFrameState(FixedNode start) { FixedNode node = start; while (true) {