diff options
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" }) { |