Skip to content

Commit ff0c6b7

Browse files
committed
add regression test
1 parent d2fb97f commit ff0c6b7

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
- // MIR for `main` before GVN
2+
+ // MIR for `main` after GVN
3+
4+
fn main() -> () {
5+
let mut _0: ();
6+
let _1: [i32; 32];
7+
let mut _4: &[i32; 32];
8+
let _5: [i32; 32];
9+
scope 1 {
10+
debug _arr => _1;
11+
let _2: [i32; 32];
12+
scope 2 {
13+
debug _barr => _2;
14+
let _3: [i32; 32];
15+
let mut _6: &[i32; 32];
16+
scope 3 {
17+
debug _darr => _3;
18+
}
19+
}
20+
}
21+
22+
bb0: {
23+
- StorageLive(_1);
24+
+ nop;
25+
_1 = [const 255_i32, const 105_i32, const 15_i32, const 39_i32, const 62_i32, const 251_i32, const 191_i32, const 178_i32, const 9_i32, const 4_i32, const 56_i32, const 221_i32, const 193_i32, const 164_i32, const 194_i32, const 197_i32, const 6_i32, const 243_i32, const 218_i32, const 171_i32, const 87_i32, const 247_i32, const 104_i32, const 159_i32, const 22_i32, const 157_i32, const 105_i32, const 31_i32, const 96_i32, const 173_i32, const 50_i32, const 1_i32];
26+
StorageLive(_2);
27+
- _2 = [const 255_i32, const 105_i32, const 15_i32, const 39_i32, const 62_i32, const 251_i32, const 191_i32, const 178_i32, const 9_i32, const 4_i32, const 56_i32, const 221_i32, const 193_i32, const 164_i32, const 194_i32, const 197_i32, const 6_i32, const 243_i32, const 218_i32, const 171_i32, const 87_i32, const 247_i32, const 104_i32, const 159_i32, const 22_i32, const 157_i32, const 105_i32, const 31_i32, const 96_i32, const 173_i32, const 50_i32, const 1_i32];
28+
+ _2 = _1;
29+
StorageLive(_3);
30+
StorageLive(_4);
31+
_6 = const main::promoted[0];
32+
_4 = &(*_6);
33+
- _3 = (*_4);
34+
+ _3 = (*_6);
35+
StorageDead(_4);
36+
_0 = const ();
37+
StorageDead(_3);
38+
StorageDead(_2);
39+
- StorageDead(_1);
40+
+ nop;
41+
return;
42+
}
43+
}
44+

tests/mir-opt/const_array_locals.rs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
//@ test-mir-pass: GVN
2+
#![feature(repr_simd)]
3+
4+
// #[repr(simd)]
5+
// struct F32x8([f32; 8]);
6+
7+
// EMIT_MIR const_array_locals.main.GVN.diff
8+
// CHECK-LABEL: fn main(
9+
#[rustfmt::skip]
10+
pub fn main() {
11+
// CHECK: let [[array_lit:_.*]]: [i32; 32];
12+
// CHECK: debug _arr => [[arr:_.*]];
13+
14+
let _arr = [
15+
255, 105, 15, 39, 62, 251, 191, 178, 9, 4, 56, 221,
16+
193, 164, 194, 197, 6, 243, 218, 171, 87, 247, 104,
17+
159, 22, 157, 105, 31, 96, 173, 50, 1,
18+
];
19+
let _barr = [
20+
255, 105, 15, 39, 62, 251, 191, 178, 9, 4, 56, 221,
21+
193, 164, 194, 197, 6, 243, 218, 171, 87, 247, 104,
22+
159, 22, 157, 105, 31, 96, 173, 50, 1,
23+
];
24+
// let _foo = [
25+
// [255, 105, 15, 39, 62, 251, 191, 178, 9, 4, 56, 221],
26+
// [193, 164, 194, 197, 6, 243, 218, 171, 87, 247, 104, 42],
27+
// ];
28+
let _darr = *&[
29+
255, 105, 15, 39, 62, 251, 191, 178, 9, 4, 56, 221,
30+
193, 164, 194, 197, 6, 243, 218, 171, 87, 247, 104,
31+
159, 22, 157, 105, 31, 96, 173, 50, 1,
32+
];
33+
34+
// consume([255, 105, 15, 39, 62, 251, 191, 178, 9, 4, 56, 221,
35+
// 193, 164, 194, 197, 6, 243, 218, 171, 87, 247, 104,
36+
// 159, 22, 157, 105, 31, 96, 173, 50, 1,]);
37+
38+
// let _f = F32x8([1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]);
39+
40+
// // ice
41+
// [[1, 0, 0], [0, 1, 0], [0, 0, 1]]; // 2D array
42+
}
43+
44+
// fn consume(_arr: [u16; 32]) {
45+
// unimplemented!()
46+
// }

0 commit comments

Comments
 (0)