diff graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/Condition.java @ 5425:0364a2a874b8

changes towards a canonical representation of comparisons: * new createNullCheckGuard helper method on CiLoweringTool * replaced NullCheckNode with IsNullNode * GuardNode and FixedGuardNode can be negated * keep a list of conditions that are true/false in CheckCastEliminationPhase * FixedGuardNode has only one condition * GraphBuilderPhase creates canonical CompareNodes * BooleanNodes can negate their usages * added junit test for canonicalized compares * removed junit test for negated instanceof * added more thorough graph comparison for junit tests * CheckCastEliminationPhase keeps track of conditions that are known to be true/false
author Lukas Stadler <lukas.stadler@jku.at>
date Tue, 22 May 2012 16:19:02 +0200
parents 136e9e8daf3d
children d89b20486d87
line wrap: on
line diff
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/Condition.java	Tue May 22 14:57:01 2012 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/Condition.java	Tue May 22 16:19:02 2012 +0200
@@ -224,6 +224,13 @@
     }
 
     /**
+     * Returns true if this condition represents an unsigned comparison. EQ and NE are not considered to be unsigned.
+     */
+    public final boolean isUnsigned() {
+        return this == Condition.BT || this == Condition.BE || this == Condition.AT || this == Condition.AE;
+    }
+
+    /**
      * Checks if this conditional operation is commutative.
      * @return {@code true} if this operation is commutative
      */
@@ -239,6 +246,19 @@
      * @return {@link Boolean#TRUE} if the comparison is known to be true,
      * {@link Boolean#FALSE} if the comparison is known to be false
      */
+    public boolean foldCondition(CiConstant lt, CiConstant rt, RiRuntime runtime) {
+        assert !lt.kind.isFloatOrDouble() && !rt.kind.isFloatOrDouble();
+        return foldCondition(lt, rt, runtime, false);
+    }
+
+    /**
+     * Attempts to fold a comparison between two constants and return the result.
+     * @param lt the constant on the left side of the comparison
+     * @param rt the constant on the right side of the comparison
+     * @param runtime the RiRuntime (might be needed to compare runtime-specific types)
+     * @param unorderedIsTrue true if an undecided float comparison should result in "true"
+     * @return true if the comparison is known to be true, false if the comparison is known to be false
+     */
     public boolean foldCondition(CiConstant lt, CiConstant rt, RiRuntime runtime, boolean unorderedIsTrue) {
         switch (lt.kind) {
             case Boolean: