summaryrefslogtreecommitdiffstats
path: root/test/474-checker-boolean-input
diff options
context:
space:
mode:
authorDavid Brazdil <dbrazdil@google.com>2015-04-20 10:14:42 +0100
committerDavid Brazdil <dbrazdil@google.com>2015-04-20 13:51:46 +0100
commit2fa194bf16678e9e8f9e2653e47cb703dbbc9738 (patch)
tree6421285a359953e0290785d94987965e0660cb23 /test/474-checker-boolean-input
parentf5091eee4abe73c64959e53bda684bd689569643 (diff)
downloadart-2fa194bf16678e9e8f9e2653e47cb703dbbc9738.zip
art-2fa194bf16678e9e8f9e2653e47cb703dbbc9738.tar.gz
art-2fa194bf16678e9e8f9e2653e47cb703dbbc9738.tar.bz2
ART: Extend list of instructions accepted as boolean inputs
Previous change allowed integer Phis as inputs of instructions expecting a boolean type. This list, however, was not exhaustive as binary operations And, Or and Xor are also valid inputs. This patch extends the list in SSAChecker. Change-Id: I5b5c9e7a17992cc4987e3a078ee23ea80028ecfc
Diffstat (limited to 'test/474-checker-boolean-input')
-rw-r--r--test/474-checker-boolean-input/src/Main.java82
1 files changed, 76 insertions, 6 deletions
diff --git a/test/474-checker-boolean-input/src/Main.java b/test/474-checker-boolean-input/src/Main.java
index 91e8d4f..1ebe14e 100644
--- a/test/474-checker-boolean-input/src/Main.java
+++ b/test/474-checker-boolean-input/src/Main.java
@@ -23,14 +23,14 @@ public class Main {
}
/*
- * Test that zero/one constants are accepted as boolean inputs.
+ * Test that zero/one constants are accepted as Boolean inputs.
*/
- // CHECK-START: boolean Main.TestIntAsBoolean() inliner (before)
+ // CHECK-START: boolean Main.TestConstAsBoolean() inliner (before)
// CHECK-DAG: [[Invoke:z\d+]] InvokeStaticOrDirect
// CHECK-DAG: BooleanNot [ [[Invoke]] ]
- // CHECK-START: boolean Main.TestIntAsBoolean() inliner (after)
+ // CHECK-START: boolean Main.TestConstAsBoolean() inliner (after)
// CHECK-DAG: [[Const:i\d+]] IntConstant 1
// CHECK-DAG: BooleanNot [ [[Const]] ]
@@ -38,13 +38,13 @@ public class Main {
return true;
}
- public static boolean TestIntAsBoolean() {
+ public static boolean TestConstAsBoolean() {
return InlineConst() != true ? true : false;
}
/*
- * Test that integer Phis are accepted as boolean inputs until we implement
- * a suitable type analysis.
+ * Test that integer Phis are accepted as Boolean inputs until
+ * we implement a suitable type analysis.
*/
// CHECK-START: boolean Main.TestPhiAsBoolean(int) inliner (before)
@@ -66,10 +66,80 @@ public class Main {
return InlinePhi(x) != true ? true : false;
}
+ /*
+ * Test that integer And is accepted as a Boolean input until
+ * we implement a suitable type analysis.
+ */
+
+ // CHECK-START: boolean Main.TestAndAsBoolean(boolean, boolean) inliner (before)
+ // CHECK-DAG: [[Invoke:z\d+]] InvokeStaticOrDirect
+ // CHECK-DAG: BooleanNot [ [[Invoke]] ]
+
+ // CHECK-START: boolean Main.TestAndAsBoolean(boolean, boolean) inliner (after)
+ // CHECK-DAG: [[And:i\d+]] And
+ // CHECK-DAG: BooleanNot [ [[And]] ]
+
+ public static boolean InlineAnd(boolean x, boolean y) {
+ return x & y;
+ }
+
+ public static boolean TestAndAsBoolean(boolean x, boolean y) {
+ return InlineAnd(x, y) != true ? true : false;
+ }
+
+ /*
+ * Test that integer Or is accepted as a Boolean input until
+ * we implement a suitable type analysis.
+ */
+
+ // CHECK-START: boolean Main.TestOrAsBoolean(boolean, boolean) inliner (before)
+ // CHECK-DAG: [[Invoke:z\d+]] InvokeStaticOrDirect
+ // CHECK-DAG: BooleanNot [ [[Invoke]] ]
+
+ // CHECK-START: boolean Main.TestOrAsBoolean(boolean, boolean) inliner (after)
+ // CHECK-DAG: [[Or:i\d+]] Or
+ // CHECK-DAG: BooleanNot [ [[Or]] ]
+
+ public static boolean InlineOr(boolean x, boolean y) {
+ return x | y;
+ }
+
+ public static boolean TestOrAsBoolean(boolean x, boolean y) {
+ return InlineOr(x, y) != true ? true : false;
+ }
+
+ /*
+ * Test that integer Xor is accepted as a Boolean input until
+ * we implement a suitable type analysis.
+ */
+
+ // CHECK-START: boolean Main.TestXorAsBoolean(boolean, boolean) inliner (before)
+ // CHECK-DAG: [[Invoke:z\d+]] InvokeStaticOrDirect
+ // CHECK-DAG: BooleanNot [ [[Invoke]] ]
+
+ // CHECK-START: boolean Main.TestXorAsBoolean(boolean, boolean) inliner (after)
+ // CHECK-DAG: [[Xor:i\d+]] Xor
+ // CHECK-DAG: BooleanNot [ [[Xor]] ]
+
+ public static boolean InlineXor(boolean x, boolean y) {
+ return x ^ y;
+ }
+
+ public static boolean TestXorAsBoolean(boolean x, boolean y) {
+ return InlineXor(x, y) != true ? true : false;
+ }
+
public static void main(String[] args) {
f1 = true;
f2 = false;
+ assertBoolEquals(false, TestConstAsBoolean());
assertBoolEquals(true, TestPhiAsBoolean(0));
assertBoolEquals(false, TestPhiAsBoolean(42));
+ assertBoolEquals(true, TestAndAsBoolean(true, false));
+ assertBoolEquals(false, TestAndAsBoolean(true, true));
+ assertBoolEquals(true, TestOrAsBoolean(false, false));
+ assertBoolEquals(false, TestOrAsBoolean(true, true));
+ assertBoolEquals(true, TestXorAsBoolean(true, true));
+ assertBoolEquals(false, TestXorAsBoolean(true, false));
}
}