about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMara Bos <m-ou.se@m-ou.se>2025-02-12 17:33:05 +0100
committerMara Bos <m-ou.se@m-ou.se>2025-03-10 12:20:05 +0100
commit4374d5461e9a4041dcbd7413c79fced0bec333fc (patch)
treec8436025cc4557a3cc62b363022dccbbf1ffab90
parentfb9ce0297682a0c54fe374800c2a41cc666d9580 (diff)
downloadrust-4374d5461e9a4041dcbd7413c79fced0bec333fc.tar.gz
rust-4374d5461e9a4041dcbd7413c79fced0bec333fc.zip
Update tests.
-rw-r--r--library/coretests/tests/num/flt2dec/mod.rs28
-rw-r--r--tests/mir-opt/funky_arms.float_to_exponential_common.GVN.32bit.panic-abort.diff (renamed from tests/mir-opt/funky_arms.float_to_exponential_common.GVN.panic-abort.diff)45
-rw-r--r--tests/mir-opt/funky_arms.float_to_exponential_common.GVN.32bit.panic-unwind.diff (renamed from tests/mir-opt/funky_arms.float_to_exponential_common.GVN.panic-unwind.diff)45
-rw-r--r--tests/mir-opt/funky_arms.float_to_exponential_common.GVN.64bit.panic-abort.diff180
-rw-r--r--tests/mir-opt/funky_arms.float_to_exponential_common.GVN.64bit.panic-unwind.diff180
-rw-r--r--tests/mir-opt/funky_arms.rs1
6 files changed, 459 insertions, 20 deletions
diff --git a/library/coretests/tests/num/flt2dec/mod.rs b/library/coretests/tests/num/flt2dec/mod.rs
index 6e74cc91c5b..c64bb0a3072 100644
--- a/library/coretests/tests/num/flt2dec/mod.rs
+++ b/library/coretests/tests/num/flt2dec/mod.rs
@@ -914,22 +914,22 @@ where
     );
 
     // very large output
-    assert_eq!(to_string(f, 0.0, Minus, 80000, false), format!("0.{:0>79999}e0", ""));
-    assert_eq!(to_string(f, 1.0e1, Minus, 80000, false), format!("1.{:0>79999}e1", ""));
-    assert_eq!(to_string(f, 1.0e0, Minus, 80000, false), format!("1.{:0>79999}e0", ""));
+    assert_eq!(to_string(f, 0.0, Minus, 50000, false), format!("0.{:0>49999}e0", ""));
+    assert_eq!(to_string(f, 1.0e1, Minus, 50000, false), format!("1.{:0>49999}e1", ""));
+    assert_eq!(to_string(f, 1.0e0, Minus, 50000, false), format!("1.{:0>49999}e0", ""));
     assert_eq!(
-        to_string(f, 1.0e-1, Minus, 80000, false),
+        to_string(f, 1.0e-1, Minus, 50000, false),
         format!(
-            "1.000000000000000055511151231257827021181583404541015625{:0>79945}\
+            "1.000000000000000055511151231257827021181583404541015625{:0>49945}\
                         e-1",
             ""
         )
     );
     assert_eq!(
-        to_string(f, 1.0e-20, Minus, 80000, false),
+        to_string(f, 1.0e-20, Minus, 50000, false),
         format!(
             "9.999999999999999451532714542095716517295037027873924471077157760\
-                         66783064379706047475337982177734375{:0>79901}e-21",
+                         66783064379706047475337982177734375{:0>49901}e-21",
             ""
         )
     );
@@ -1150,18 +1150,18 @@ where
     );
 
     // very large output
-    assert_eq!(to_string(f, 0.0, Minus, 80000), format!("0.{:0>80000}", ""));
-    assert_eq!(to_string(f, 1.0e1, Minus, 80000), format!("10.{:0>80000}", ""));
-    assert_eq!(to_string(f, 1.0e0, Minus, 80000), format!("1.{:0>80000}", ""));
+    assert_eq!(to_string(f, 0.0, Minus, 50000), format!("0.{:0>50000}", ""));
+    assert_eq!(to_string(f, 1.0e1, Minus, 50000), format!("10.{:0>50000}", ""));
+    assert_eq!(to_string(f, 1.0e0, Minus, 50000), format!("1.{:0>50000}", ""));
     assert_eq!(
-        to_string(f, 1.0e-1, Minus, 80000),
-        format!("0.1000000000000000055511151231257827021181583404541015625{:0>79945}", "")
+        to_string(f, 1.0e-1, Minus, 50000),
+        format!("0.1000000000000000055511151231257827021181583404541015625{:0>49945}", "")
     );
     assert_eq!(
-        to_string(f, 1.0e-20, Minus, 80000),
+        to_string(f, 1.0e-20, Minus, 50000),
         format!(
             "0.0000000000000000000099999999999999994515327145420957165172950370\
-                          2787392447107715776066783064379706047475337982177734375{:0>79881}",
+                          2787392447107715776066783064379706047475337982177734375{:0>49881}",
             ""
         )
     );
diff --git a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.panic-abort.diff b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.32bit.panic-abort.diff
index a1be927e1c0..45fc7365d8d 100644
--- a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.panic-abort.diff
+++ b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.32bit.panic-abort.diff
@@ -29,6 +29,16 @@
                   debug precision => _8;
                   let _8: usize;
                   scope 5 (inlined Formatter::<'_>::precision) {
+                      let mut _22: std::option::Option<u16>;
+                      scope 6 (inlined Option::<u16>::map::<usize, {closure@Formatter<'_>::precision::{closure#0}}>) {
+                          let mut _23: isize;
+                          let _24: u16;
+                          let mut _25: usize;
+                          scope 7 {
+                              scope 8 (inlined Formatter::<'_>::precision::{closure#0}) {
+                              }
+                          }
+                      }
                   }
               }
           }
@@ -65,9 +75,12 @@
   
       bb3: {
           StorageLive(_6);
-          _6 = copy (((*_1).0: std::fmt::FormattingOptions).4: std::option::Option<usize>);
-          _7 = discriminant(_6);
-          switchInt(move _7) -> [1: bb4, 0: bb6, otherwise: bb9];
+          StorageLive(_24);
+          StorageLive(_22);
+          _22 = copy (((*_1).0: std::fmt::FormattingOptions).4: std::option::Option<u16>);
+          StorageLive(_23);
+          _23 = discriminant(_22);
+          switchInt(move _23) -> [0: bb11, 1: bb12, otherwise: bb10];
       }
   
       bb4: {
@@ -135,7 +148,33 @@
       }
   
       bb9: {
+          StorageDead(_23);
+          StorageDead(_22);
+          StorageDead(_24);
+          _7 = discriminant(_6);
+          switchInt(move _7) -> [1: bb4, 0: bb6, otherwise: bb10];
+      }
+  
+      bb10: {
           unreachable;
       }
+  
+      bb11: {
+          _6 = const Option::<usize>::None;
+          goto -> bb9;
+      }
+  
+      bb12: {
+          _24 = move ((_22 as Some).0: u16);
+          StorageLive(_25);
+          _25 = copy _24 as usize (IntToInt);
+          _6 = Option::<usize>::Some(move _25);
+          StorageDead(_25);
+          goto -> bb9;
+      }
+  }
+  
+  ALLOC0 (size: 8, align: 4) {
+      00 00 00 00 __ __ __ __                         │ ....░░░░
   }
   
diff --git a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.panic-unwind.diff b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.32bit.panic-unwind.diff
index 87ab71feb2f..578d2c2194b 100644
--- a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.panic-unwind.diff
+++ b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.32bit.panic-unwind.diff
@@ -29,6 +29,16 @@
                   debug precision => _8;
                   let _8: usize;
                   scope 5 (inlined Formatter::<'_>::precision) {
+                      let mut _22: std::option::Option<u16>;
+                      scope 6 (inlined Option::<u16>::map::<usize, {closure@Formatter<'_>::precision::{closure#0}}>) {
+                          let mut _23: isize;
+                          let _24: u16;
+                          let mut _25: usize;
+                          scope 7 {
+                              scope 8 (inlined Formatter::<'_>::precision::{closure#0}) {
+                              }
+                          }
+                      }
                   }
               }
           }
@@ -65,9 +75,12 @@
   
       bb3: {
           StorageLive(_6);
-          _6 = copy (((*_1).0: std::fmt::FormattingOptions).4: std::option::Option<usize>);
-          _7 = discriminant(_6);
-          switchInt(move _7) -> [1: bb4, 0: bb6, otherwise: bb9];
+          StorageLive(_24);
+          StorageLive(_22);
+          _22 = copy (((*_1).0: std::fmt::FormattingOptions).4: std::option::Option<u16>);
+          StorageLive(_23);
+          _23 = discriminant(_22);
+          switchInt(move _23) -> [0: bb11, 1: bb12, otherwise: bb10];
       }
   
       bb4: {
@@ -135,7 +148,33 @@
       }
   
       bb9: {
+          StorageDead(_23);
+          StorageDead(_22);
+          StorageDead(_24);
+          _7 = discriminant(_6);
+          switchInt(move _7) -> [1: bb4, 0: bb6, otherwise: bb10];
+      }
+  
+      bb10: {
           unreachable;
       }
+  
+      bb11: {
+          _6 = const Option::<usize>::None;
+          goto -> bb9;
+      }
+  
+      bb12: {
+          _24 = move ((_22 as Some).0: u16);
+          StorageLive(_25);
+          _25 = copy _24 as usize (IntToInt);
+          _6 = Option::<usize>::Some(move _25);
+          StorageDead(_25);
+          goto -> bb9;
+      }
+  }
+  
+  ALLOC0 (size: 8, align: 4) {
+      00 00 00 00 __ __ __ __                         │ ....░░░░
   }
   
diff --git a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.64bit.panic-abort.diff b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.64bit.panic-abort.diff
new file mode 100644
index 00000000000..5f0f7d6cc74
--- /dev/null
+++ b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.64bit.panic-abort.diff
@@ -0,0 +1,180 @@
+- // MIR for `float_to_exponential_common` before GVN
++ // MIR for `float_to_exponential_common` after GVN
+  
+  fn float_to_exponential_common(_1: &mut Formatter<'_>, _2: &T, _3: bool) -> Result<(), std::fmt::Error> {
+      debug fmt => _1;
+      debug num => _2;
+      debug upper => _3;
+      let mut _0: std::result::Result<(), std::fmt::Error>;
+      let _4: bool;
+      let mut _6: std::option::Option<usize>;
+      let mut _7: isize;
+      let mut _9: &mut std::fmt::Formatter<'_>;
+      let mut _10: &T;
+      let mut _11: core::num::flt2dec::Sign;
+      let mut _12: u32;
+      let mut _13: u32;
+      let mut _14: usize;
+      let mut _15: bool;
+      let mut _16: &mut std::fmt::Formatter<'_>;
+      let mut _17: &T;
+      let mut _18: core::num::flt2dec::Sign;
+      let mut _19: bool;
+      scope 1 {
+          debug force_sign => _4;
+          let _5: core::num::flt2dec::Sign;
+          scope 2 {
+              debug sign => _5;
+              scope 3 {
+                  debug precision => _8;
+                  let _8: usize;
+                  scope 5 (inlined Formatter::<'_>::precision) {
+                      let mut _22: std::option::Option<u16>;
+                      scope 6 (inlined Option::<u16>::map::<usize, {closure@Formatter<'_>::precision::{closure#0}}>) {
+                          let mut _23: isize;
+                          let _24: u16;
+                          let mut _25: usize;
+                          scope 7 {
+                              scope 8 (inlined Formatter::<'_>::precision::{closure#0}) {
+                              }
+                          }
+                      }
+                  }
+              }
+          }
+      }
+      scope 4 (inlined Formatter::<'_>::sign_plus) {
+          let mut _20: u32;
+          let mut _21: u32;
+      }
+  
+      bb0: {
+          StorageLive(_4);
+          StorageLive(_20);
+          StorageLive(_21);
+          _21 = copy (((*_1).0: std::fmt::FormattingOptions).0: u32);
+          _20 = BitAnd(move _21, const 1_u32);
+          StorageDead(_21);
+          _4 = Ne(move _20, const 0_u32);
+          StorageDead(_20);
+          StorageLive(_5);
+          switchInt(copy _4) -> [0: bb2, otherwise: bb1];
+      }
+  
+      bb1: {
+-         _5 = MinusPlus;
++         _5 = const MinusPlus;
+          goto -> bb3;
+      }
+  
+      bb2: {
+-         _5 = core::num::flt2dec::Sign::Minus;
++         _5 = const core::num::flt2dec::Sign::Minus;
+          goto -> bb3;
+      }
+  
+      bb3: {
+          StorageLive(_6);
+          StorageLive(_24);
+          StorageLive(_22);
+          _22 = copy (((*_1).0: std::fmt::FormattingOptions).4: std::option::Option<u16>);
+          StorageLive(_23);
+          _23 = discriminant(_22);
+          switchInt(move _23) -> [0: bb11, 1: bb12, otherwise: bb10];
+      }
+  
+      bb4: {
+-         StorageLive(_8);
++         nop;
+          _8 = copy ((_6 as Some).0: usize);
+          StorageLive(_9);
+          _9 = copy _1;
+          StorageLive(_10);
+          _10 = copy _2;
+          StorageLive(_11);
+          _11 = copy _5;
+          StorageLive(_12);
+          StorageLive(_13);
+          StorageLive(_14);
+          _14 = copy _8;
+-         _13 = move _14 as u32 (IntToInt);
++         _13 = copy _8 as u32 (IntToInt);
+          StorageDead(_14);
+          _12 = Add(move _13, const 1_u32);
+          StorageDead(_13);
+          StorageLive(_15);
+          _15 = copy _3;
+-         _0 = float_to_exponential_common_exact::<T>(move _9, move _10, move _11, move _12, move _15) -> [return: bb5, unwind unreachable];
++         _0 = float_to_exponential_common_exact::<T>(copy _1, copy _2, move _11, move _12, copy _3) -> [return: bb5, unwind unreachable];
+      }
+  
+      bb5: {
+          StorageDead(_15);
+          StorageDead(_12);
+          StorageDead(_11);
+          StorageDead(_10);
+          StorageDead(_9);
+-         StorageDead(_8);
++         nop;
+          goto -> bb8;
+      }
+  
+      bb6: {
+          StorageLive(_16);
+          _16 = copy _1;
+          StorageLive(_17);
+          _17 = copy _2;
+          StorageLive(_18);
+          _18 = copy _5;
+          StorageLive(_19);
+          _19 = copy _3;
+-         _0 = float_to_exponential_common_shortest::<T>(move _16, move _17, move _18, move _19) -> [return: bb7, unwind unreachable];
++         _0 = float_to_exponential_common_shortest::<T>(copy _1, copy _2, move _18, copy _3) -> [return: bb7, unwind unreachable];
+      }
+  
+      bb7: {
+          StorageDead(_19);
+          StorageDead(_18);
+          StorageDead(_17);
+          StorageDead(_16);
+          goto -> bb8;
+      }
+  
+      bb8: {
+          StorageDead(_5);
+          StorageDead(_4);
+          StorageDead(_6);
+          return;
+      }
+  
+      bb9: {
+          StorageDead(_23);
+          StorageDead(_22);
+          StorageDead(_24);
+          _7 = discriminant(_6);
+          switchInt(move _7) -> [1: bb4, 0: bb6, otherwise: bb10];
+      }
+  
+      bb10: {
+          unreachable;
+      }
+  
+      bb11: {
+          _6 = const Option::<usize>::None;
+          goto -> bb9;
+      }
+  
+      bb12: {
+          _24 = move ((_22 as Some).0: u16);
+          StorageLive(_25);
+          _25 = copy _24 as usize (IntToInt);
+          _6 = Option::<usize>::Some(move _25);
+          StorageDead(_25);
+          goto -> bb9;
+      }
+  }
+  
+  ALLOC0 (size: 16, align: 8) {
+      00 00 00 00 00 00 00 00 __ __ __ __ __ __ __ __ │ ........░░░░░░░░
+  }
+  
diff --git a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.64bit.panic-unwind.diff b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.64bit.panic-unwind.diff
new file mode 100644
index 00000000000..10cc46a8b82
--- /dev/null
+++ b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.64bit.panic-unwind.diff
@@ -0,0 +1,180 @@
+- // MIR for `float_to_exponential_common` before GVN
++ // MIR for `float_to_exponential_common` after GVN
+  
+  fn float_to_exponential_common(_1: &mut Formatter<'_>, _2: &T, _3: bool) -> Result<(), std::fmt::Error> {
+      debug fmt => _1;
+      debug num => _2;
+      debug upper => _3;
+      let mut _0: std::result::Result<(), std::fmt::Error>;
+      let _4: bool;
+      let mut _6: std::option::Option<usize>;
+      let mut _7: isize;
+      let mut _9: &mut std::fmt::Formatter<'_>;
+      let mut _10: &T;
+      let mut _11: core::num::flt2dec::Sign;
+      let mut _12: u32;
+      let mut _13: u32;
+      let mut _14: usize;
+      let mut _15: bool;
+      let mut _16: &mut std::fmt::Formatter<'_>;
+      let mut _17: &T;
+      let mut _18: core::num::flt2dec::Sign;
+      let mut _19: bool;
+      scope 1 {
+          debug force_sign => _4;
+          let _5: core::num::flt2dec::Sign;
+          scope 2 {
+              debug sign => _5;
+              scope 3 {
+                  debug precision => _8;
+                  let _8: usize;
+                  scope 5 (inlined Formatter::<'_>::precision) {
+                      let mut _22: std::option::Option<u16>;
+                      scope 6 (inlined Option::<u16>::map::<usize, {closure@Formatter<'_>::precision::{closure#0}}>) {
+                          let mut _23: isize;
+                          let _24: u16;
+                          let mut _25: usize;
+                          scope 7 {
+                              scope 8 (inlined Formatter::<'_>::precision::{closure#0}) {
+                              }
+                          }
+                      }
+                  }
+              }
+          }
+      }
+      scope 4 (inlined Formatter::<'_>::sign_plus) {
+          let mut _20: u32;
+          let mut _21: u32;
+      }
+  
+      bb0: {
+          StorageLive(_4);
+          StorageLive(_20);
+          StorageLive(_21);
+          _21 = copy (((*_1).0: std::fmt::FormattingOptions).0: u32);
+          _20 = BitAnd(move _21, const 1_u32);
+          StorageDead(_21);
+          _4 = Ne(move _20, const 0_u32);
+          StorageDead(_20);
+          StorageLive(_5);
+          switchInt(copy _4) -> [0: bb2, otherwise: bb1];
+      }
+  
+      bb1: {
+-         _5 = MinusPlus;
++         _5 = const MinusPlus;
+          goto -> bb3;
+      }
+  
+      bb2: {
+-         _5 = core::num::flt2dec::Sign::Minus;
++         _5 = const core::num::flt2dec::Sign::Minus;
+          goto -> bb3;
+      }
+  
+      bb3: {
+          StorageLive(_6);
+          StorageLive(_24);
+          StorageLive(_22);
+          _22 = copy (((*_1).0: std::fmt::FormattingOptions).4: std::option::Option<u16>);
+          StorageLive(_23);
+          _23 = discriminant(_22);
+          switchInt(move _23) -> [0: bb11, 1: bb12, otherwise: bb10];
+      }
+  
+      bb4: {
+-         StorageLive(_8);
++         nop;
+          _8 = copy ((_6 as Some).0: usize);
+          StorageLive(_9);
+          _9 = copy _1;
+          StorageLive(_10);
+          _10 = copy _2;
+          StorageLive(_11);
+          _11 = copy _5;
+          StorageLive(_12);
+          StorageLive(_13);
+          StorageLive(_14);
+          _14 = copy _8;
+-         _13 = move _14 as u32 (IntToInt);
++         _13 = copy _8 as u32 (IntToInt);
+          StorageDead(_14);
+          _12 = Add(move _13, const 1_u32);
+          StorageDead(_13);
+          StorageLive(_15);
+          _15 = copy _3;
+-         _0 = float_to_exponential_common_exact::<T>(move _9, move _10, move _11, move _12, move _15) -> [return: bb5, unwind continue];
++         _0 = float_to_exponential_common_exact::<T>(copy _1, copy _2, move _11, move _12, copy _3) -> [return: bb5, unwind continue];
+      }
+  
+      bb5: {
+          StorageDead(_15);
+          StorageDead(_12);
+          StorageDead(_11);
+          StorageDead(_10);
+          StorageDead(_9);
+-         StorageDead(_8);
++         nop;
+          goto -> bb8;
+      }
+  
+      bb6: {
+          StorageLive(_16);
+          _16 = copy _1;
+          StorageLive(_17);
+          _17 = copy _2;
+          StorageLive(_18);
+          _18 = copy _5;
+          StorageLive(_19);
+          _19 = copy _3;
+-         _0 = float_to_exponential_common_shortest::<T>(move _16, move _17, move _18, move _19) -> [return: bb7, unwind continue];
++         _0 = float_to_exponential_common_shortest::<T>(copy _1, copy _2, move _18, copy _3) -> [return: bb7, unwind continue];
+      }
+  
+      bb7: {
+          StorageDead(_19);
+          StorageDead(_18);
+          StorageDead(_17);
+          StorageDead(_16);
+          goto -> bb8;
+      }
+  
+      bb8: {
+          StorageDead(_5);
+          StorageDead(_4);
+          StorageDead(_6);
+          return;
+      }
+  
+      bb9: {
+          StorageDead(_23);
+          StorageDead(_22);
+          StorageDead(_24);
+          _7 = discriminant(_6);
+          switchInt(move _7) -> [1: bb4, 0: bb6, otherwise: bb10];
+      }
+  
+      bb10: {
+          unreachable;
+      }
+  
+      bb11: {
+          _6 = const Option::<usize>::None;
+          goto -> bb9;
+      }
+  
+      bb12: {
+          _24 = move ((_22 as Some).0: u16);
+          StorageLive(_25);
+          _25 = copy _24 as usize (IntToInt);
+          _6 = Option::<usize>::Some(move _25);
+          StorageDead(_25);
+          goto -> bb9;
+      }
+  }
+  
+  ALLOC0 (size: 16, align: 8) {
+      00 00 00 00 00 00 00 00 __ __ __ __ __ __ __ __ │ ........░░░░░░░░
+  }
+  
diff --git a/tests/mir-opt/funky_arms.rs b/tests/mir-opt/funky_arms.rs
index fc3691049eb..403a22ebed3 100644
--- a/tests/mir-opt/funky_arms.rs
+++ b/tests/mir-opt/funky_arms.rs
@@ -1,5 +1,6 @@
 // skip-filecheck
 // EMIT_MIR_FOR_EACH_PANIC_STRATEGY
+// EMIT_MIR_FOR_EACH_BIT_WIDTH
 
 #![feature(flt2dec)]