src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/calc/SignedRemNode.java
changeset 57537 ecc6e394475f
parent 54724 62f373a53296
equal deleted inserted replaced
57536:67cce1b84a9a 57537:ecc6e394475f
   115         if (self == null) {
   115         if (self == null) {
   116             // If the node was not yet created, then we do not know its usages yet.
   116             // If the node was not yet created, then we do not know its usages yet.
   117             return false;
   117             return false;
   118         }
   118         }
   119 
   119 
   120         int compareAgainstZero = 0;
   120         for (Node usage : self.usages()) {
   121         int usageCount = self.getUsageCount();
       
   122         for (int i = 0; i < usageCount; i++) {
       
   123             Node usage = self.getUsageAt(i);
       
   124             if (usage instanceof IntegerEqualsNode) {
   121             if (usage instanceof IntegerEqualsNode) {
   125                 IntegerEqualsNode equalsNode = (IntegerEqualsNode) usage;
   122                 IntegerEqualsNode equalsNode = (IntegerEqualsNode) usage;
   126                 ValueNode node = equalsNode.getY();
   123                 ValueNode node = equalsNode.getY();
   127                 if (node == self) {
   124                 if (node == self) {
   128                     node = equalsNode.getX();
   125                     node = equalsNode.getX();
   129                 }
   126                 }
   130                 if (node instanceof ConstantNode) {
   127                 if (node instanceof ConstantNode) {
   131                     ConstantNode constantNode = (ConstantNode) node;
   128                     ConstantNode constantNode = (ConstantNode) node;
   132                     Constant constant = constantNode.asConstant();
   129                     Constant constant = constantNode.asConstant();
   133                     if (constant instanceof PrimitiveConstant && ((PrimitiveConstant) constant).asLong() == 0) {
   130                     if (constant instanceof PrimitiveConstant && ((PrimitiveConstant) constant).asLong() == 0) {
   134                         compareAgainstZero++;
   131                         continue;
   135                     }
   132                     }
   136                 }
   133                 }
   137             }
   134             }
       
   135             return false;
   138         }
   136         }
   139         return compareAgainstZero == usageCount;
   137         return true;
   140     }
   138     }
   141 
   139 
   142     @Override
   140     @Override
   143     public void generate(NodeLIRBuilderTool gen) {
   141     public void generate(NodeLIRBuilderTool gen) {
   144         gen.setResult(this, gen.getLIRGeneratorTool().getArithmetic().emitRem(gen.operand(getX()), gen.operand(getY()), gen.state(this)));
   142         gen.setResult(this, gen.getLIRGeneratorTool().getArithmetic().emitRem(gen.operand(getX()), gen.operand(getY()), gen.state(this)));