src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/calc/AddNode.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/calc

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/calc/AddNode.java

Print this page




  86                 if (sub.getY() == forY) {
  87                     // (a - b) + b
  88                     return sub.getX();
  89                 }
  90             }
  91             if (forY instanceof SubNode) {
  92                 SubNode sub = (SubNode) forY;
  93                 if (sub.getY() == forX) {
  94                     // b + (a - b)
  95                     return sub.getX();
  96                 }
  97             }
  98         }
  99         if (forY.isConstant()) {
 100             Constant c = forY.asConstant();
 101             if (op.isNeutral(c)) {
 102                 return forX;
 103             }
 104             if (associative) {
 105                 // canonicalize expressions like "(a + 1) + 2"
 106                 BinaryNode reassociated = reassociate(this, ValueNode.isConstantPredicate(), forX, forY);
 107                 if (reassociated != this) {
 108                     return reassociated;
 109                 }
 110             }
 111         }
 112         if (forX instanceof NegateNode) {
 113             return BinaryArithmeticNode.sub(forY, ((NegateNode) forX).getValue());
 114         } else if (forY instanceof NegateNode) {
 115             return BinaryArithmeticNode.sub(forX, ((NegateNode) forY).getValue());
 116         }
 117         return this;
 118     }
 119 
 120     @Override
 121     public void generate(NodeLIRBuilderTool nodeValueMap, ArithmeticLIRGeneratorTool gen) {
 122         Value op1 = nodeValueMap.operand(getX());
 123         assert op1 != null : getX() + ", this=" + this;
 124         Value op2 = nodeValueMap.operand(getY());
 125         if (shouldSwapInputs(nodeValueMap)) {
 126             Value tmp = op1;


  86                 if (sub.getY() == forY) {
  87                     // (a - b) + b
  88                     return sub.getX();
  89                 }
  90             }
  91             if (forY instanceof SubNode) {
  92                 SubNode sub = (SubNode) forY;
  93                 if (sub.getY() == forX) {
  94                     // b + (a - b)
  95                     return sub.getX();
  96                 }
  97             }
  98         }
  99         if (forY.isConstant()) {
 100             Constant c = forY.asConstant();
 101             if (op.isNeutral(c)) {
 102                 return forX;
 103             }
 104             if (associative) {
 105                 // canonicalize expressions like "(a + 1) + 2"
 106                 ValueNode reassociated = reassociate(this, ValueNode.isConstantPredicate(), forX, forY);
 107                 if (reassociated != this) {
 108                     return reassociated;
 109                 }
 110             }
 111         }
 112         if (forX instanceof NegateNode) {
 113             return BinaryArithmeticNode.sub(forY, ((NegateNode) forX).getValue());
 114         } else if (forY instanceof NegateNode) {
 115             return BinaryArithmeticNode.sub(forX, ((NegateNode) forY).getValue());
 116         }
 117         return this;
 118     }
 119 
 120     @Override
 121     public void generate(NodeLIRBuilderTool nodeValueMap, ArithmeticLIRGeneratorTool gen) {
 122         Value op1 = nodeValueMap.operand(getX());
 123         assert op1 != null : getX() + ", this=" + this;
 124         Value op2 = nodeValueMap.operand(getY());
 125         if (shouldSwapInputs(nodeValueMap)) {
 126             Value tmp = op1;
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/calc/AddNode.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File