summary refs log tree commit diff
path: root/tests/mir-opt
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-08-06 19:02:52 +0000
committerbors <bors@rust-lang.org>2024-08-06 19:02:52 +0000
commit3f5fd8dd41153bc5fdca9427e9e05be2c767ba23 (patch)
tree01cdc48561c6f259221b76ee764f3e8fba492708 /tests/mir-opt
parent051478957371ee0084a7c0913941d2a8c4757bb9 (diff)
parent1cc8da5c1015f8ce0268f856a4de42cb9e77e218 (diff)
downloadrust-1.80.1.tar.gz
rust-1.80.1.zip
Auto merge of #128635 - pietroalbini:pa-1.80.1, r=pietroalbini 1.80.1
Prepare Rust 1.80.1 point release

The point release is scheduled to include:

* https://github.com/rust-lang/rust/pull/128271
* https://github.com/rust-lang/rust/pull/128618
Diffstat (limited to 'tests/mir-opt')
-rw-r--r--tests/mir-opt/jump_threading.floats.JumpThreading.panic-abort.diff59
-rw-r--r--tests/mir-opt/jump_threading.floats.JumpThreading.panic-unwind.diff59
-rw-r--r--tests/mir-opt/jump_threading.rs12
3 files changed, 130 insertions, 0 deletions
diff --git a/tests/mir-opt/jump_threading.floats.JumpThreading.panic-abort.diff b/tests/mir-opt/jump_threading.floats.JumpThreading.panic-abort.diff
new file mode 100644
index 00000000000..6ca37e96d29
--- /dev/null
+++ b/tests/mir-opt/jump_threading.floats.JumpThreading.panic-abort.diff
@@ -0,0 +1,59 @@
+- // MIR for `floats` before JumpThreading
++ // MIR for `floats` after JumpThreading
+  
+  fn floats() -> u32 {
+      let mut _0: u32;
+      let _1: f64;
+      let mut _2: bool;
+      let mut _3: bool;
+      let mut _4: f64;
+      scope 1 {
+          debug x => _1;
+      }
+  
+      bb0: {
+          StorageLive(_1);
+          StorageLive(_2);
+          _2 = const true;
+-         switchInt(move _2) -> [0: bb2, otherwise: bb1];
++         goto -> bb1;
+      }
+  
+      bb1: {
+          _1 = const -0f64;
+          goto -> bb3;
+      }
+  
+      bb2: {
+          _1 = const 1f64;
+          goto -> bb3;
+      }
+  
+      bb3: {
+          StorageDead(_2);
+          StorageLive(_3);
+          StorageLive(_4);
+          _4 = _1;
+          _3 = Eq(move _4, const 0f64);
+          switchInt(move _3) -> [0: bb5, otherwise: bb4];
+      }
+  
+      bb4: {
+          StorageDead(_4);
+          _0 = const 0_u32;
+          goto -> bb6;
+      }
+  
+      bb5: {
+          StorageDead(_4);
+          _0 = const 1_u32;
+          goto -> bb6;
+      }
+  
+      bb6: {
+          StorageDead(_3);
+          StorageDead(_1);
+          return;
+      }
+  }
+  
diff --git a/tests/mir-opt/jump_threading.floats.JumpThreading.panic-unwind.diff b/tests/mir-opt/jump_threading.floats.JumpThreading.panic-unwind.diff
new file mode 100644
index 00000000000..6ca37e96d29
--- /dev/null
+++ b/tests/mir-opt/jump_threading.floats.JumpThreading.panic-unwind.diff
@@ -0,0 +1,59 @@
+- // MIR for `floats` before JumpThreading
++ // MIR for `floats` after JumpThreading
+  
+  fn floats() -> u32 {
+      let mut _0: u32;
+      let _1: f64;
+      let mut _2: bool;
+      let mut _3: bool;
+      let mut _4: f64;
+      scope 1 {
+          debug x => _1;
+      }
+  
+      bb0: {
+          StorageLive(_1);
+          StorageLive(_2);
+          _2 = const true;
+-         switchInt(move _2) -> [0: bb2, otherwise: bb1];
++         goto -> bb1;
+      }
+  
+      bb1: {
+          _1 = const -0f64;
+          goto -> bb3;
+      }
+  
+      bb2: {
+          _1 = const 1f64;
+          goto -> bb3;
+      }
+  
+      bb3: {
+          StorageDead(_2);
+          StorageLive(_3);
+          StorageLive(_4);
+          _4 = _1;
+          _3 = Eq(move _4, const 0f64);
+          switchInt(move _3) -> [0: bb5, otherwise: bb4];
+      }
+  
+      bb4: {
+          StorageDead(_4);
+          _0 = const 0_u32;
+          goto -> bb6;
+      }
+  
+      bb5: {
+          StorageDead(_4);
+          _0 = const 1_u32;
+          goto -> bb6;
+      }
+  
+      bb6: {
+          StorageDead(_3);
+          StorageDead(_1);
+          return;
+      }
+  }
+  
diff --git a/tests/mir-opt/jump_threading.rs b/tests/mir-opt/jump_threading.rs
index b4c13371680..002200e6fb4 100644
--- a/tests/mir-opt/jump_threading.rs
+++ b/tests/mir-opt/jump_threading.rs
@@ -506,6 +506,16 @@ fn assume(a: u8, b: bool) -> u8 {
     }
 }
 
+fn floats() -> u32 {
+    // CHECK-LABEL: fn floats(
+    // CHECK: switchInt(
+
+    // Test for issue #128243, where float equality was assumed to be bitwise.
+    // When adding float support, it must be ensured that this continues working properly.
+    let x = if true { -0.0 } else { 1.0 };
+    if x == 0.0 { 0 } else { 1 }
+}
+
 fn main() {
     // CHECK-LABEL: fn main(
     too_complex(Ok(0));
@@ -520,6 +530,7 @@ fn main() {
     disappearing_bb(7);
     aggregate(7);
     assume(7, false);
+    floats();
 }
 
 // EMIT_MIR jump_threading.too_complex.JumpThreading.diff
@@ -534,3 +545,4 @@ fn main() {
 // EMIT_MIR jump_threading.disappearing_bb.JumpThreading.diff
 // EMIT_MIR jump_threading.aggregate.JumpThreading.diff
 // EMIT_MIR jump_threading.assume.JumpThreading.diff
+// EMIT_MIR jump_threading.floats.JumpThreading.diff