about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/mir-opt/jump_threading.bitwise_not.JumpThreading.panic-abort.diff6
-rw-r--r--tests/mir-opt/jump_threading.bitwise_not.JumpThreading.panic-unwind.diff6
-rw-r--r--tests/mir-opt/jump_threading.logical_not.JumpThreading.panic-abort.diff46
-rw-r--r--tests/mir-opt/jump_threading.logical_not.JumpThreading.panic-unwind.diff46
-rw-r--r--tests/mir-opt/jump_threading.rs14
5 files changed, 109 insertions, 9 deletions
diff --git a/tests/mir-opt/jump_threading.bitwise_not.JumpThreading.panic-abort.diff b/tests/mir-opt/jump_threading.bitwise_not.JumpThreading.panic-abort.diff
index 047441e6099..c3272f21d6c 100644
--- a/tests/mir-opt/jump_threading.bitwise_not.JumpThreading.panic-abort.diff
+++ b/tests/mir-opt/jump_threading.bitwise_not.JumpThreading.panic-abort.diff
@@ -3,7 +3,7 @@
   
   fn bitwise_not() -> i32 {
       let mut _0: i32;
-      let mut _1: i32;
+      let _1: i32;
       let mut _2: bool;
       let mut _3: i32;
       let mut _4: i32;
@@ -13,7 +13,6 @@
   
       bb0: {
           StorageLive(_1);
-          _1 = const 0_i32;
           _1 = const 1_i32;
           StorageLive(_2);
           StorageLive(_3);
@@ -22,7 +21,8 @@
           _3 = Not(move _4);
           StorageDead(_4);
           _2 = Eq(move _3, const 0_i32);
-          switchInt(move _2) -> [0: bb2, otherwise: bb1];
+-         switchInt(move _2) -> [0: bb2, otherwise: bb1];
++         goto -> bb2;
       }
   
       bb1: {
diff --git a/tests/mir-opt/jump_threading.bitwise_not.JumpThreading.panic-unwind.diff b/tests/mir-opt/jump_threading.bitwise_not.JumpThreading.panic-unwind.diff
index 047441e6099..c3272f21d6c 100644
--- a/tests/mir-opt/jump_threading.bitwise_not.JumpThreading.panic-unwind.diff
+++ b/tests/mir-opt/jump_threading.bitwise_not.JumpThreading.panic-unwind.diff
@@ -3,7 +3,7 @@
   
   fn bitwise_not() -> i32 {
       let mut _0: i32;
-      let mut _1: i32;
+      let _1: i32;
       let mut _2: bool;
       let mut _3: i32;
       let mut _4: i32;
@@ -13,7 +13,6 @@
   
       bb0: {
           StorageLive(_1);
-          _1 = const 0_i32;
           _1 = const 1_i32;
           StorageLive(_2);
           StorageLive(_3);
@@ -22,7 +21,8 @@
           _3 = Not(move _4);
           StorageDead(_4);
           _2 = Eq(move _3, const 0_i32);
-          switchInt(move _2) -> [0: bb2, otherwise: bb1];
+-         switchInt(move _2) -> [0: bb2, otherwise: bb1];
++         goto -> bb2;
       }
   
       bb1: {
diff --git a/tests/mir-opt/jump_threading.logical_not.JumpThreading.panic-abort.diff b/tests/mir-opt/jump_threading.logical_not.JumpThreading.panic-abort.diff
new file mode 100644
index 00000000000..ad8be1ef5a1
--- /dev/null
+++ b/tests/mir-opt/jump_threading.logical_not.JumpThreading.panic-abort.diff
@@ -0,0 +1,46 @@
+- // MIR for `logical_not` before JumpThreading
++ // MIR for `logical_not` after JumpThreading
+  
+  fn logical_not() -> i32 {
+      let mut _0: i32;
+      let _1: bool;
+      let mut _2: bool;
+      let mut _3: bool;
+      let mut _4: bool;
+      scope 1 {
+          debug a => _1;
+      }
+  
+      bb0: {
+          StorageLive(_1);
+          _1 = const false;
+          StorageLive(_2);
+          StorageLive(_3);
+          StorageLive(_4);
+          _4 = copy _1;
+          _3 = Not(move _4);
+          StorageDead(_4);
+          _2 = Eq(move _3, const true);
+-         switchInt(move _2) -> [0: bb2, otherwise: bb1];
++         goto -> bb1;
+      }
+  
+      bb1: {
+          StorageDead(_3);
+          _0 = const 1_i32;
+          goto -> bb3;
+      }
+  
+      bb2: {
+          StorageDead(_3);
+          _0 = const 0_i32;
+          goto -> bb3;
+      }
+  
+      bb3: {
+          StorageDead(_2);
+          StorageDead(_1);
+          return;
+      }
+  }
+  
diff --git a/tests/mir-opt/jump_threading.logical_not.JumpThreading.panic-unwind.diff b/tests/mir-opt/jump_threading.logical_not.JumpThreading.panic-unwind.diff
new file mode 100644
index 00000000000..ad8be1ef5a1
--- /dev/null
+++ b/tests/mir-opt/jump_threading.logical_not.JumpThreading.panic-unwind.diff
@@ -0,0 +1,46 @@
+- // MIR for `logical_not` before JumpThreading
++ // MIR for `logical_not` after JumpThreading
+  
+  fn logical_not() -> i32 {
+      let mut _0: i32;
+      let _1: bool;
+      let mut _2: bool;
+      let mut _3: bool;
+      let mut _4: bool;
+      scope 1 {
+          debug a => _1;
+      }
+  
+      bb0: {
+          StorageLive(_1);
+          _1 = const false;
+          StorageLive(_2);
+          StorageLive(_3);
+          StorageLive(_4);
+          _4 = copy _1;
+          _3 = Not(move _4);
+          StorageDead(_4);
+          _2 = Eq(move _3, const true);
+-         switchInt(move _2) -> [0: bb2, otherwise: bb1];
++         goto -> bb1;
+      }
+  
+      bb1: {
+          StorageDead(_3);
+          _0 = const 1_i32;
+          goto -> bb3;
+      }
+  
+      bb2: {
+          StorageDead(_3);
+          _0 = const 0_i32;
+          goto -> bb3;
+      }
+  
+      bb3: {
+          StorageDead(_2);
+          StorageDead(_1);
+          return;
+      }
+  }
+  
diff --git a/tests/mir-opt/jump_threading.rs b/tests/mir-opt/jump_threading.rs
index 743ee8e728b..009e1060700 100644
--- a/tests/mir-opt/jump_threading.rs
+++ b/tests/mir-opt/jump_threading.rs
@@ -532,14 +532,19 @@ fn floats() -> u32 {
 
 pub fn bitwise_not() -> i32 {
     // CHECK-LABEL: fn bitwise_not(
-    // CHECK: switchInt(
 
     // Test for #131195, which was optimizing `!a == b` into `a != b`.
-    let mut a: i32 = 0;
-    a = 1;
+    let a = 1;
     if !a == 0 { 1 } else { 0 }
 }
 
+pub fn logical_not() -> i32 {
+    // CHECK-LABEL: fn logical_not(
+
+    let a = false;
+    if !a == true { 1 } else { 0 }
+}
+
 fn main() {
     // CHECK-LABEL: fn main(
     too_complex(Ok(0));
@@ -555,6 +560,8 @@ fn main() {
     aggregate(7);
     assume(7, false);
     floats();
+    bitwise_not();
+    logical_not();
 }
 
 // EMIT_MIR jump_threading.too_complex.JumpThreading.diff
@@ -572,3 +579,4 @@ fn main() {
 // EMIT_MIR jump_threading.aggregate_copy.JumpThreading.diff
 // EMIT_MIR jump_threading.floats.JumpThreading.diff
 // EMIT_MIR jump_threading.bitwise_not.JumpThreading.diff
+// EMIT_MIR jump_threading.logical_not.JumpThreading.diff