Mercurial > hg > graal-jvmci-8
diff graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ShortCircuitBooleanNode.java @ 11409:1f302b6e16b0
Introduce LogicNegationNode and remove Negatable interface.
author | Roland Schatz <roland.schatz@oracle.com> |
---|---|
date | Sat, 24 Aug 2013 14:38:11 +0200 |
parents | ec4c7c33e8e5 |
children |
line wrap: on
line diff
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ShortCircuitBooleanNode.java Sat Aug 24 14:32:57 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ShortCircuitBooleanNode.java Sat Aug 24 14:38:11 2013 +0200 @@ -23,12 +23,11 @@ package com.oracle.graal.nodes; import com.oracle.graal.graph.*; -import com.oracle.graal.nodes.spi.*; /** * Base class for the short-circuit boolean operators. */ -public abstract class ShortCircuitBooleanNode extends LogicNode implements Negatable, Node.IterableNodeType { +public abstract class ShortCircuitBooleanNode extends LogicNode implements Node.IterableNodeType { @Input private LogicNode x; @Input private LogicNode y; @@ -68,14 +67,27 @@ return shortCircuitProbability; } - @Override - public Negatable negate(LogicNode condition) { - if (condition == x) { - xNegated = !xNegated; + protected abstract ShortCircuitBooleanNode createCopy(LogicNode xCond, boolean xNeg, LogicNode yCond, boolean yNeg, double probability); + + protected ShortCircuitBooleanNode canonicalizeNegation() { + LogicNode xCond = x; + boolean xNeg = xNegated; + while (xCond instanceof LogicNegationNode) { + xCond = ((LogicNegationNode) xCond).getInput(); + xNeg = !xNeg; } - if (condition == y) { - yNegated = !yNegated; + + LogicNode yCond = y; + boolean yNeg = yNegated; + while (yCond instanceof LogicNegationNode) { + yCond = ((LogicNegationNode) yCond).getInput(); + yNeg = !yNeg; } - return this; + + if (xCond != x || yCond != y) { + return graph().unique(createCopy(xCond, xNeg, yCond, yNeg, shortCircuitProbability)); + } else { + return null; + } } }