Skip to content

Commit ae6f97c

Browse files
committed
Make slice_filter a pre-codegen test.
1 parent 789dd0b commit ae6f97c

10 files changed

+341
-1082
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// compile-flags: -O -Zmir-opt-level=2 -Cdebuginfo=2
2+
// ignore-debug: standard library debug assertions add a panic that breaks this optimization
3+
4+
#![crate_type = "lib"]
5+
6+
pub fn variant_a(input: &[(usize, usize, usize, usize)]) -> usize {
7+
input.iter().filter(|(a, b, c, d)| a <= c && d <= b || c <= a && b <= d).count()
8+
}
9+
10+
pub fn variant_b(input: &[(usize, usize, usize, usize)]) -> usize {
11+
input.iter().filter(|&&(a, b, c, d)| a <= c && d <= b || c <= a && b <= d).count()
12+
}
13+
14+
// EMIT_MIR slice_filter.variant_a-{closure#0}.PreCodegen.after.mir
15+
// EMIT_MIR slice_filter.variant_b-{closure#0}.PreCodegen.after.mir

tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir

Lines changed: 231 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
// MIR for `variant_b::{closure#0}` after PreCodegen
2+
3+
fn variant_b::{closure#0}(_1: &mut [closure@$DIR/slice_filter.rs:11:25: 11:41], _2: &&(usize, usize, usize, usize)) -> bool {
4+
let mut _0: bool; // return place in scope 0 at $DIR/slice_filter.rs:+0:42: +0:42
5+
let mut _3: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:40
6+
let _4: usize; // in scope 0 at $DIR/slice_filter.rs:+0:29: +0:30
7+
let mut _5: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:40
8+
let _6: usize; // in scope 0 at $DIR/slice_filter.rs:+0:32: +0:33
9+
let mut _7: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:40
10+
let _8: usize; // in scope 0 at $DIR/slice_filter.rs:+0:35: +0:36
11+
let mut _9: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:40
12+
let _10: usize; // in scope 0 at $DIR/slice_filter.rs:+0:38: +0:39
13+
let mut _11: bool; // in scope 0 at $DIR/slice_filter.rs:+0:42: +0:48
14+
let mut _12: bool; // in scope 0 at $DIR/slice_filter.rs:+0:42: +0:58
15+
let mut _13: bool; // in scope 0 at $DIR/slice_filter.rs:+0:52: +0:58
16+
let mut _14: bool; // in scope 0 at $DIR/slice_filter.rs:+0:62: +0:68
17+
let mut _15: bool; // in scope 0 at $DIR/slice_filter.rs:+0:62: +0:78
18+
let mut _16: bool; // in scope 0 at $DIR/slice_filter.rs:+0:72: +0:78
19+
scope 1 {
20+
debug a => _4; // in scope 1 at $DIR/slice_filter.rs:+0:29: +0:30
21+
debug b => _6; // in scope 1 at $DIR/slice_filter.rs:+0:32: +0:33
22+
debug c => _8; // in scope 1 at $DIR/slice_filter.rs:+0:35: +0:36
23+
debug d => _10; // in scope 1 at $DIR/slice_filter.rs:+0:38: +0:39
24+
}
25+
26+
bb0: {
27+
_3 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:29: +0:30
28+
_4 = ((*_3).0: usize); // scope 0 at $DIR/slice_filter.rs:+0:29: +0:30
29+
_5 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:32: +0:33
30+
_6 = ((*_5).1: usize); // scope 0 at $DIR/slice_filter.rs:+0:32: +0:33
31+
_7 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:35: +0:36
32+
_8 = ((*_7).2: usize); // scope 0 at $DIR/slice_filter.rs:+0:35: +0:36
33+
_9 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:38: +0:39
34+
_10 = ((*_9).3: usize); // scope 0 at $DIR/slice_filter.rs:+0:38: +0:39
35+
StorageLive(_12); // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58
36+
StorageLive(_11); // scope 1 at $DIR/slice_filter.rs:+0:42: +0:48
37+
_11 = Le(_4, _8); // scope 1 at $DIR/slice_filter.rs:+0:42: +0:48
38+
switchInt(move _11) -> [0: bb1, otherwise: bb2]; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58
39+
}
40+
41+
bb1: {
42+
_12 = const false; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58
43+
goto -> bb3; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58
44+
}
45+
46+
bb2: {
47+
StorageLive(_13); // scope 1 at $DIR/slice_filter.rs:+0:52: +0:58
48+
_13 = Le(_10, _6); // scope 1 at $DIR/slice_filter.rs:+0:52: +0:58
49+
_12 = move _13; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58
50+
goto -> bb3; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58
51+
}
52+
53+
bb3: {
54+
StorageDead(_13); // scope 1 at $DIR/slice_filter.rs:+0:57: +0:58
55+
StorageDead(_11); // scope 1 at $DIR/slice_filter.rs:+0:57: +0:58
56+
switchInt(move _12) -> [0: bb4, otherwise: bb8]; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78
57+
}
58+
59+
bb4: {
60+
StorageLive(_15); // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78
61+
StorageLive(_14); // scope 1 at $DIR/slice_filter.rs:+0:62: +0:68
62+
_14 = Le(_8, _4); // scope 1 at $DIR/slice_filter.rs:+0:62: +0:68
63+
switchInt(move _14) -> [0: bb5, otherwise: bb6]; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78
64+
}
65+
66+
bb5: {
67+
_15 = const false; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78
68+
goto -> bb7; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78
69+
}
70+
71+
bb6: {
72+
StorageLive(_16); // scope 1 at $DIR/slice_filter.rs:+0:72: +0:78
73+
_16 = Le(_6, _10); // scope 1 at $DIR/slice_filter.rs:+0:72: +0:78
74+
_15 = move _16; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78
75+
goto -> bb7; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78
76+
}
77+
78+
bb7: {
79+
StorageDead(_16); // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78
80+
StorageDead(_14); // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78
81+
_0 = move _15; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78
82+
goto -> bb9; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78
83+
}
84+
85+
bb8: {
86+
_0 = const true; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78
87+
goto -> bb9; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78
88+
}
89+
90+
bb9: {
91+
StorageDead(_15); // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78
92+
StorageDead(_12); // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78
93+
return; // scope 0 at $DIR/slice_filter.rs:+0:78: +0:78
94+
}
95+
}

tests/mir-opt/slice_filter.rs

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)