diff options
| author | 2016-02-15 12:48:36 +0600 | |
|---|---|---|
| committer | 2016-03-11 18:28:55 +0600 | |
| commit | bdd7935c2adc3ad190ee87958e714a36f33cedae (patch) | |
| tree | 64563d52d699d63c22574dbc97e6d5410df94ac3 /test/458-checker-instruction-simplification/src/Main.java | |
| parent | 2af7213a4e0d395fe22dcdce6ec10a3bd131023d (diff) | |
Revert "Revert "Revert "Revert "Change condition to opposite if lhs is constant""""
This reverts commit d4aee949b3dd976295201b5310f13aa2df40afa1.
Change-Id: I505b8c9863c310a3a708f580b00d425b750c9541
Diffstat (limited to 'test/458-checker-instruction-simplification/src/Main.java')
| -rw-r--r-- | test/458-checker-instruction-simplification/src/Main.java | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/test/458-checker-instruction-simplification/src/Main.java b/test/458-checker-instruction-simplification/src/Main.java index 8640148795..dd4ffe45e4 100644 --- a/test/458-checker-instruction-simplification/src/Main.java +++ b/test/458-checker-instruction-simplification/src/Main.java @@ -1601,6 +1601,34 @@ public class Main { return (short) (value & 0x17fff); } + /// 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:z\d+>> 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:z\d+>> 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: <<Const42:d\d+>> DoubleConstant 42 + /// CHECK-DAG: <<Result:d\d+>> InvokeStaticOrDirect + /// CHECK-DAG: <<CMP:i\d+>> Compare [<<Const42>>,<<Result>>] + + /// CHECK-START: int Main.intReverseConditionNaN(int) instruction_simplifier (after) + /// CHECK-DAG: <<Const42:d\d+>> DoubleConstant 42 + /// CHECK-DAG: <<Result:d\d+>> InvokeStaticOrDirect + /// CHECK-DAG: <<EQ:z\d+>> Equal [<<Result>>,<<Const42>>] + + public static int intReverseConditionNaN(int i) { + return (42 != Math.sqrt(i)) ? 13 : 54; + } + public static int runSmaliTest(String name, boolean input) { try { Class<?> c = Class.forName("SmaliTests"); @@ -1611,7 +1639,7 @@ public class Main { } } - public static void main(String[] args) { +public static void main(String[] args) { int arg = 123456; assertLongEquals(Add0(arg), arg); @@ -1740,6 +1768,9 @@ public class Main { assertIntEquals(intAnd0x17fffToShort(Integer.MIN_VALUE), 0); assertIntEquals(intAnd0x17fffToShort(Integer.MAX_VALUE), Short.MAX_VALUE); + assertIntEquals(intReverseCondition(41), 13); + assertIntEquals(intReverseConditionNaN(-5), 13); + for (String condition : new String[] { "Equal", "NotEqual" }) { for (String constant : new String[] { "True", "False" }) { for (String side : new String[] { "Rhs", "Lhs" }) { |