From f9f196c55f3b25c3b09350cd8ed5d7ead31f1757 Mon Sep 17 00:00:00 2001 From: Anton Shamin Date: Tue, 8 Sep 2015 17:33:16 +0600 Subject: 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 Signed-off-by: Serguei Katkov --- .../src/Main.java | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'test/458-checker-instruction-simplification/src/Main.java') 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: <> ParameterValue + /// CHECK-DAG: <> IntConstant 42 + /// CHECK-DAG: <> LessThanOrEqual [<>,<>] + + /// CHECK-START: int Main.intReverseCondition(int) instruction_simplifier (after) + /// CHECK-DAG: <> ParameterValue + /// CHECK-DAG: <> IntConstant 42 + /// CHECK-DAG: <> GreaterThanOrEqual [<>,<>] + + public static int intReverseCondition(int i) { + return (42 > i) ? 13 : 54; + } + + /// CHECK-START: int Main.intReverseConditionNaN(int) instruction_simplifier (before) + /// CHECK-DAG: <> ParameterValue + /// CHECK-DAG: <> DoubleConstant 42 + /// CHECK-DAG: <> InvokeStaticOrDirect [<>] + /// CHECK-DAG: <> Compare [<>,<>] + + /// CHECK-START: int Main.intReverseConditionNaN(int) instruction_simplifier (after) + /// CHECK-DAG: <> ParameterValue + /// CHECK-DAG: <> DoubleConstant 42 + /// CHECK-DAG: <> InvokeStaticOrDirect [<>] + /// CHECK-DAG: <> Equal [<>,<>] + + 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; -- cgit v1.2.3-59-g8ed1b