Skip to content

Commit 8f7e441

Browse files
committed
Add mir-opt test.
1 parent 8ba0cd6 commit 8f7e441

3 files changed

+519
-0
lines changed

tests/mir-opt/slice_filter.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
fn main() {
2+
let input = vec![];
3+
4+
// 1761ms on my machine
5+
let _variant_a_result = variant_a(&input);
6+
7+
// 656ms on my machine
8+
let _variant_b_result = variant_b(&input);
9+
}
10+
11+
12+
// EMIT_MIR slice_filter.variant_a-{closure#0}.DestinationPropagation.diff
13+
pub fn variant_a(input: &[(usize, usize, usize, usize)]) -> usize {
14+
input.iter().filter(|(a, b, c, d)| a <= c && d <= b || c <= a && b <= d).count()
15+
}
16+
17+
18+
// EMIT_MIR slice_filter.variant_b-{closure#0}.DestinationPropagation.diff
19+
pub fn variant_b(input: &[(usize, usize, usize, usize)]) -> usize {
20+
input.iter().filter(|&&(a, b, c, d)| a <= c && d <= b || c <= a && b <= d).count()
21+
}

0 commit comments

Comments
 (0)