< prev index next >

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

Print this page

        

@@ -48,10 +48,11 @@
 import jdk.vm.ci.meta.Constant;
 import jdk.vm.ci.meta.ConstantReflectionProvider;
 import jdk.vm.ci.meta.JavaKind;
 import jdk.vm.ci.meta.MetaAccessProvider;
 import jdk.vm.ci.meta.PrimitiveConstant;
+import jdk.vm.ci.meta.TriState;
 
 @NodeInfo(shortName = "<")
 public final class IntegerLessThanNode extends IntegerLowerThanNode {
     public static final NodeClass<IntegerLessThanNode> TYPE = NodeClass.create(IntegerLessThanNode.class);
     private static final LessThanOp OP = new LessThanOp();

@@ -223,11 +224,10 @@
                                 long newConstant = yConstant - xConstant;
                                 return IntegerLessThanNode.create(addNode.getX(), ConstantNode.forIntegerStamp(xStamp, newConstant), view);
                             }
                         }
                     }
-
                 }
             }
 
             if (forX.stamp(view) instanceof IntegerStamp) {
                 assert forY.stamp(view) instanceof IntegerStamp;

@@ -294,6 +294,31 @@
         @Override
         protected IntegerStamp forInteger(int bits, long min, long max) {
             return StampFactory.forInteger(bits, cast(min, bits), cast(max, bits));
         }
     }
+
+    @Override
+    public TriState implies(boolean thisNegated, LogicNode other) {
+        if (!thisNegated) {
+            if (other instanceof IntegerLessThanNode) {
+                ValueNode otherX = ((IntegerLessThanNode) other).getX();
+                ValueNode otherY = ((IntegerLessThanNode) other).getY();
+                // x < y => !y < x
+                if (getX() == otherY && getY() == otherX) {
+                    return TriState.FALSE;
+                }
+            }
+
+            // x < y => !x == y
+            // x < y => !y == x
+            if (other instanceof IntegerEqualsNode) {
+                ValueNode otherX = ((IntegerEqualsNode) other).getX();
+                ValueNode otherY = ((IntegerEqualsNode) other).getY();
+                if ((getX() == otherX && getY() == otherY) || (getX() == otherY && getY() == otherX)) {
+                    return TriState.FALSE;
+                }
+            }
+        }
+        return super.implies(thisNegated, other);
+    }
 }
< prev index next >