# HG changeset patch # User Lukas Stadler # Date 1405681709 -7200 # Node ID 7d9c2a7f6ec95323747bf75c34b38c6e58da9876 # Parent f2a4042d97874382979dcabb3157016cec35b040 use getKind() only for primitive constants in Condition.foldCondition diff -r f2a4042d9787 -r 7d9c2a7f6ec9 graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/calc/Condition.java --- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/calc/Condition.java Fri Jul 18 01:26:43 2014 +0200 +++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/calc/Condition.java Fri Jul 18 13:08:29 2014 +0200 @@ -337,128 +337,130 @@ * false */ public boolean foldCondition(Constant lt, Constant rt, ConstantReflectionProvider constantReflection, boolean unorderedIsTrue) { - switch (lt.getKind()) { - case Boolean: - case Byte: - case Char: - case Short: - case Int: { - int x = lt.asInt(); - int y = rt.asInt(); - switch (this) { - case EQ: - return x == y; - case NE: - return x != y; - case LT: - return x < y; - case LE: - return x <= y; - case GT: - return x > y; - case GE: - return x >= y; - case AE: - return UnsignedMath.aboveOrEqual(x, y); - case BE: - return UnsignedMath.belowOrEqual(x, y); - case AT: - return UnsignedMath.aboveThan(x, y); - case BT: - return UnsignedMath.belowThan(x, y); - default: - throw new GraalInternalError("expected condition: %s", this); - } - } - case Long: { - long x = lt.asLong(); - long y = rt.asLong(); - switch (this) { - case EQ: - return x == y; - case NE: - return x != y; - case LT: - return x < y; - case LE: - return x <= y; - case GT: - return x > y; - case GE: - return x >= y; - case AE: - return UnsignedMath.aboveOrEqual(x, y); - case BE: - return UnsignedMath.belowOrEqual(x, y); - case AT: - return UnsignedMath.aboveThan(x, y); - case BT: - return UnsignedMath.belowThan(x, y); - default: - throw new GraalInternalError("expected condition: %s", this); - } - } - case Object: { - Boolean equal = constantReflection.constantEquals(lt, rt); - if (equal != null) { + if (lt instanceof PrimitiveConstant) { + switch (lt.getKind()) { + case Boolean: + case Byte: + case Char: + case Short: + case Int: { + int x = lt.asInt(); + int y = rt.asInt(); switch (this) { case EQ: - return equal.booleanValue(); + return x == y; case NE: - return !equal.booleanValue(); + return x != y; + case LT: + return x < y; + case LE: + return x <= y; + case GT: + return x > y; + case GE: + return x >= y; + case AE: + return UnsignedMath.aboveOrEqual(x, y); + case BE: + return UnsignedMath.belowOrEqual(x, y); + case AT: + return UnsignedMath.aboveThan(x, y); + case BT: + return UnsignedMath.belowThan(x, y); + default: + throw new GraalInternalError("expected condition: %s", this); + } + } + case Long: { + long x = lt.asLong(); + long y = rt.asLong(); + switch (this) { + case EQ: + return x == y; + case NE: + return x != y; + case LT: + return x < y; + case LE: + return x <= y; + case GT: + return x > y; + case GE: + return x >= y; + case AE: + return UnsignedMath.aboveOrEqual(x, y); + case BE: + return UnsignedMath.belowOrEqual(x, y); + case AT: + return UnsignedMath.aboveThan(x, y); + case BT: + return UnsignedMath.belowThan(x, y); default: throw new GraalInternalError("expected condition: %s", this); } } - } - case Float: { - float x = lt.asFloat(); - float y = rt.asFloat(); - if (Float.isNaN(x) || Float.isNaN(y)) { - return unorderedIsTrue; + case Float: { + float x = lt.asFloat(); + float y = rt.asFloat(); + if (Float.isNaN(x) || Float.isNaN(y)) { + return unorderedIsTrue; + } + switch (this) { + case EQ: + return x == y; + case NE: + return x != y; + case LT: + return x < y; + case LE: + return x <= y; + case GT: + return x > y; + case GE: + return x >= y; + default: + throw new GraalInternalError("expected condition: %s", this); + } } - switch (this) { - case EQ: - return x == y; - case NE: - return x != y; - case LT: - return x < y; - case LE: - return x <= y; - case GT: - return x > y; - case GE: - return x >= y; - default: - throw new GraalInternalError("expected condition: %s", this); + case Double: { + double x = lt.asDouble(); + double y = rt.asDouble(); + if (Double.isNaN(x) || Double.isNaN(y)) { + return unorderedIsTrue; + } + switch (this) { + case EQ: + return x == y; + case NE: + return x != y; + case LT: + return x < y; + case LE: + return x <= y; + case GT: + return x > y; + case GE: + return x >= y; + default: + throw new GraalInternalError("expected condition: %s", this); + } } + default: + throw new GraalInternalError("expected value kind %s while folding condition: %s", lt.getKind(), this); } - case Double: { - double x = lt.asDouble(); - double y = rt.asDouble(); - if (Double.isNaN(x) || Double.isNaN(y)) { - return unorderedIsTrue; - } - switch (this) { - case EQ: - return x == y; - case NE: - return x != y; - case LT: - return x < y; - case LE: - return x <= y; - case GT: - return x > y; - case GE: - return x >= y; - default: - throw new GraalInternalError("expected condition: %s", this); - } + } else { + Boolean equal = constantReflection.constantEquals(lt, rt); + if (equal == null) { + throw new GraalInternalError("could not fold %s %s %s", lt, this, rt); } - default: - throw new GraalInternalError("expected value kind %s while folding condition: %s", lt.getKind(), this); + switch (this) { + case EQ: + return equal.booleanValue(); + case NE: + return !equal.booleanValue(); + default: + throw new GraalInternalError("expected condition: %s", this); + } } }