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/building/match/sort_candidates.disjoint_ranges.SimplifyCfg-initial.after.mir70
-rw-r--r--tests/mir-opt/building/match/sort_candidates.rs23
2 files changed, 42 insertions, 51 deletions
diff --git a/tests/mir-opt/building/match/sort_candidates.disjoint_ranges.SimplifyCfg-initial.after.mir b/tests/mir-opt/building/match/sort_candidates.disjoint_ranges.SimplifyCfg-initial.after.mir
index 149c13a8c2f..80d3c2e5c23 100644
--- a/tests/mir-opt/building/match/sort_candidates.disjoint_ranges.SimplifyCfg-initial.after.mir
+++ b/tests/mir-opt/building/match/sort_candidates.disjoint_ranges.SimplifyCfg-initial.after.mir
@@ -1,38 +1,24 @@
 // MIR for `disjoint_ranges` after SimplifyCfg-initial
 
-fn disjoint_ranges() -> () {
-    let mut _0: ();
-    let _1: i32;
-    let _3: i32;
+fn disjoint_ranges(_1: i32, _2: bool) -> u32 {
+    debug x => _1;
+    debug b => _2;
+    let mut _0: u32;
+    let mut _3: bool;
     let mut _4: bool;
     let mut _5: bool;
     let mut _6: bool;
-    let mut _7: bool;
-    let mut _8: &i32;
-    let mut _9: bool;
-    scope 1 {
-        debug x => _1;
-        let _2: bool;
-        scope 2 {
-            debug b => _2;
-        }
-    }
+    let mut _7: &i32;
+    let mut _8: bool;
 
     bb0: {
-        StorageLive(_1);
-        _1 = const 3_i32;
-        FakeRead(ForLet(None), _1);
-        StorageLive(_2);
-        _2 = const true;
-        FakeRead(ForLet(None), _2);
-        StorageLive(_3);
         PlaceMention(_1);
-        _6 = Le(const 0_i32, _1);
-        switchInt(move _6) -> [0: bb3, otherwise: bb8];
+        _5 = Le(const 0_i32, _1);
+        switchInt(move _5) -> [0: bb3, otherwise: bb8];
     }
 
     bb1: {
-        _3 = const 3_i32;
+        _0 = const 3_u32;
         goto -> bb14;
     }
 
@@ -41,8 +27,8 @@ fn disjoint_ranges() -> () {
     }
 
     bb3: {
-        _4 = Le(const 10_i32, _1);
-        switchInt(move _4) -> [0: bb5, otherwise: bb7];
+        _3 = Le(const 10_i32, _1);
+        switchInt(move _3) -> [0: bb5, otherwise: bb7];
     }
 
     bb4: {
@@ -58,49 +44,45 @@ fn disjoint_ranges() -> () {
     }
 
     bb7: {
-        _5 = Le(_1, const 20_i32);
-        switchInt(move _5) -> [0: bb5, otherwise: bb4];
+        _4 = Le(_1, const 20_i32);
+        switchInt(move _4) -> [0: bb5, otherwise: bb4];
     }
 
     bb8: {
-        _7 = Lt(_1, const 10_i32);
-        switchInt(move _7) -> [0: bb3, otherwise: bb2];
+        _6 = Lt(_1, const 10_i32);
+        switchInt(move _6) -> [0: bb3, otherwise: bb2];
     }
 
     bb9: {
-        _8 = &fake _1;
-        StorageLive(_9);
-        _9 = _2;
-        switchInt(move _9) -> [0: bb11, otherwise: bb10];
+        _7 = &fake _1;
+        StorageLive(_8);
+        _8 = _2;
+        switchInt(move _8) -> [0: bb11, otherwise: bb10];
     }
 
     bb10: {
-        StorageDead(_9);
-        FakeRead(ForMatchGuard, _8);
-        _3 = const 0_i32;
+        StorageDead(_8);
+        FakeRead(ForMatchGuard, _7);
+        _0 = const 0_u32;
         goto -> bb14;
     }
 
     bb11: {
-        StorageDead(_9);
+        StorageDead(_8);
         falseEdge -> [real: bb1, imaginary: bb4];
     }
 
     bb12: {
-        _3 = const 1_i32;
+        _0 = const 1_u32;
         goto -> bb14;
     }
 
     bb13: {
-        _3 = const 2_i32;
+        _0 = const 2_u32;
         goto -> bb14;
     }
 
     bb14: {
-        StorageDead(_3);
-        _0 = const ();
-        StorageDead(_2);
-        StorageDead(_1);
         return;
     }
 }
diff --git a/tests/mir-opt/building/match/sort_candidates.rs b/tests/mir-opt/building/match/sort_candidates.rs
index 2f93cd767bd..a2583ff8284 100644
--- a/tests/mir-opt/building/match/sort_candidates.rs
+++ b/tests/mir-opt/building/match/sort_candidates.rs
@@ -1,10 +1,14 @@
-// skip-filecheck
 // Check specific cases of sorting candidates in match lowering.
 #![feature(exclusive_range_pattern)]
 
 // EMIT_MIR sort_candidates.constant_eq.SimplifyCfg-initial.after.mir
 fn constant_eq(s: &str, b: bool) -> u32 {
     // Check that we only test "a" once
+
+    // CHECK-LABEL: fn constant_eq(
+    // CHECK: bb0: {
+    // CHECK: [[a:_.*]] = const "a";
+    // CHECK-NOT: {{_.*}} = const "a";
     match (s, b) {
         ("a", _) if true => 1,
         ("b", true) => 2,
@@ -15,18 +19,23 @@ fn constant_eq(s: &str, b: bool) -> u32 {
 }
 
 // EMIT_MIR sort_candidates.disjoint_ranges.SimplifyCfg-initial.after.mir
-fn disjoint_ranges() {
-    let x = 3;
-    let b = true;
+fn disjoint_ranges(x: i32, b: bool) -> u32 {
+    // When `(0..=10).contains(x) && !b`, we should jump to the last arm without testing the two
+    // other candidates.
 
-    // When `(0..=10).contains(x) && !b`, we should jump to the last arm
-    // without testing two other candidates.
+    // CHECK-LABEL: fn disjoint_ranges(
+    // CHECK: debug b => _2;
+    // CHECK: bb0: {
+    // CHECK: switchInt(_2) -> [0: [[jump:bb.*]], otherwise: {{bb.*}}];
+    // CHECK: [[jump]]: {
+    // CHECK-NEXT: _0 = const 3_u32;
+    // CHECK-NEXT: return;
     match x {
         0..10 if b => 0,
         10..=20 => 1,
         -1 => 2,
         _ => 3,
-    };
+    }
 }
 
 fn main() {}