about summary refs log tree commit diff
path: root/tests/mir-opt/instsimplify/bool_compare.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/mir-opt/instsimplify/bool_compare.rs')
-rw-r--r--tests/mir-opt/instsimplify/bool_compare.rs68
1 files changed, 68 insertions, 0 deletions
diff --git a/tests/mir-opt/instsimplify/bool_compare.rs b/tests/mir-opt/instsimplify/bool_compare.rs
new file mode 100644
index 00000000000..77f427b0d7c
--- /dev/null
+++ b/tests/mir-opt/instsimplify/bool_compare.rs
@@ -0,0 +1,68 @@
+// unit-test: InstSimplify
+
+// EMIT_MIR bool_compare.eq_true.InstSimplify.diff
+fn eq_true(x: bool) -> u32 {
+    // CHECK-LABEL: fn eq_true(
+    // CHECK-NOT: Eq(
+    if x == true { 0 } else { 1 }
+}
+
+// EMIT_MIR bool_compare.true_eq.InstSimplify.diff
+fn true_eq(x: bool) -> u32 {
+    // CHECK-LABEL: fn true_eq(
+    // CHECK-NOT: Eq(
+    if true == x { 0 } else { 1 }
+}
+
+// EMIT_MIR bool_compare.ne_true.InstSimplify.diff
+fn ne_true(x: bool) -> u32 {
+    // CHECK-LABEL: fn ne_true(
+    // CHECK: Not(
+    if x != true { 0 } else { 1 }
+}
+
+// EMIT_MIR bool_compare.true_ne.InstSimplify.diff
+fn true_ne(x: bool) -> u32 {
+    // CHECK-LABEL: fn true_ne(
+    // CHECK: Not(
+    if true != x { 0 } else { 1 }
+}
+
+// EMIT_MIR bool_compare.eq_false.InstSimplify.diff
+fn eq_false(x: bool) -> u32 {
+    // CHECK-LABEL: fn eq_false(
+    // CHECK: Not(
+    if x == false { 0 } else { 1 }
+}
+
+// EMIT_MIR bool_compare.false_eq.InstSimplify.diff
+fn false_eq(x: bool) -> u32 {
+    // CHECK-LABEL: fn false_eq(
+    // CHECK: Not(
+    if false == x { 0 } else { 1 }
+}
+
+// EMIT_MIR bool_compare.ne_false.InstSimplify.diff
+fn ne_false(x: bool) -> u32 {
+    // CHECK-LABEL: fn ne_false(
+    // CHECK-NOT: Ne(
+    if x != false { 0 } else { 1 }
+}
+
+// EMIT_MIR bool_compare.false_ne.InstSimplify.diff
+fn false_ne(x: bool) -> u32 {
+    // CHECK-LABEL: fn false_ne(
+    // CHECK-NOT: Ne(
+    if false != x { 0 } else { 1 }
+}
+
+fn main() {
+    eq_true(false);
+    true_eq(false);
+    ne_true(false);
+    true_ne(false);
+    eq_false(false);
+    false_eq(false);
+    ne_false(false);
+    false_ne(false);
+}