diff options
| author | 2015-09-08 17:33:16 +0600 | |
|---|---|---|
| committer | 2016-01-12 13:07:06 +0000 | |
| commit | f9f196c55f3b25c3b09350cd8ed5d7ead31f1757 (patch) | |
| tree | 0be051a729b2f2674c3148d8734e5520713ad546 /test/458-checker-instruction-simplification/src/Main.java | |
| parent | c3ba07ef76549129705af28173070b88a1c39531 (diff) | |
Change condition to opposite if lhs is constant
Swap operands if lhs is constant. Handeled unsigned comparison
in insruction simplifier. Fixed NaN comparison: no matter what
bias is set result of Equal and NotEqual operations should not
depend on it. Added checker tests.
Change-Id: I5a9ac25fb10f2705127a52534867cee43368ed1b
Signed-off-by: Anton Shamin <anton.shamin@intel.com>
Signed-off-by: Serguei Katkov <serguei.i.katkov@intel.com>
Diffstat (limited to 'test/458-checker-instruction-simplification/src/Main.java')
| -rw-r--r-- | test/458-checker-instruction-simplification/src/Main.java | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/458-checker-instruction-simplification/src/Main.java b/test/458-checker-instruction-simplification/src/Main.java index 0fd7801d48..bc080e92de 100644 --- a/test/458-checker-instruction-simplification/src/Main.java +++ b/test/458-checker-instruction-simplification/src/Main.java @@ -1332,6 +1332,36 @@ public class Main { return ((d > 42.0) != false) ? 13 : 54; } + /// CHECK-START: int Main.intReverseCondition(int) instruction_simplifier (before) + /// CHECK-DAG: <<Arg:i\d+>> ParameterValue + /// CHECK-DAG: <<Const42:i\d+>> IntConstant 42 + /// CHECK-DAG: <<LE>> LessThanOrEqual [<<Const42>>,<<Arg>>] + + /// CHECK-START: int Main.intReverseCondition(int) instruction_simplifier (after) + /// CHECK-DAG: <<Arg:i\d+>> ParameterValue + /// CHECK-DAG: <<Const42:i\d+>> IntConstant 42 + /// CHECK-DAG: <<GE>> GreaterThanOrEqual [<<Arg>>,<<Const42>>] + + public static int intReverseCondition(int i) { + return (42 > i) ? 13 : 54; + } + + /// CHECK-START: int Main.intReverseConditionNaN(int) instruction_simplifier (before) + /// CHECK-DAG: <<Arg:i\d+>> ParameterValue + /// CHECK-DAG: <<Const42:d\d+>> DoubleConstant 42 + /// CHECK-DAG: <<ResDouble>> InvokeStaticOrDirect [<<Arg>>] + /// CHECK-DAG: <<CMP>> Compare [<<Const42>>,<<ResDouble>>] + + /// CHECK-START: int Main.intReverseConditionNaN(int) instruction_simplifier (after) + /// CHECK-DAG: <<Arg:i\d+>> ParameterValue + /// CHECK-DAG: <<Const42:d\d+>> DoubleConstant 42 + /// CHECK-DAG: <<ResDouble>> InvokeStaticOrDirect [<<Arg>>] + /// CHECK-DAG: <<EQ>> Equal [<<ResDouble>>,<<Const42>>] + + public static int intReverseConditionNaN(int i) { + return (42 != Math.sqrt(i)) ? 13 : 54; + } + public static void main(String[] args) { int arg = 123456; @@ -1413,6 +1443,8 @@ public class Main { assertIntEquals(floatConditionNotEqualOne(43.0f), 13); assertIntEquals(doubleConditionEqualZero(6.0), 54); assertIntEquals(doubleConditionEqualZero(43.0), 13); + assertIntEquals(intReverseCondition(41), 13); + assertIntEquals(intReverseConditionNaN(-5), 13); } public static boolean booleanField; |