Skip to content

Commit 52ecad9

Browse files
committed
Add a mir-opt test for == on arrays
1 parent 4a997ee commit 52ecad9

7 files changed

Lines changed: 151 additions & 0 deletions
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// MIR for `eq_ipv4` after PreCodegen
2+
3+
fn eq_ipv4(_1: &[u8; 4], _2: &[u8; 4]) -> bool {
4+
debug a => _1;
5+
debug b => _2;
6+
let mut _0: bool;
7+
scope 1 (inlined std::cmp::impls::<impl PartialEq for &[u8; 4]>::eq) {
8+
scope 2 (inlined array::equality::<impl PartialEq for [u8; 4]>::eq) {
9+
scope 3 (inlined <u8 as array::equality::SpecArrayEq<u8, 4>>::spec_eq) {
10+
}
11+
}
12+
}
13+
14+
bb0: {
15+
_0 = raw_eq::<[u8; 4]>(move _1, move _2) -> [return: bb1, unwind unreachable];
16+
}
17+
18+
bb1: {
19+
return;
20+
}
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// MIR for `eq_ipv4` after PreCodegen
2+
3+
fn eq_ipv4(_1: &[u8; 4], _2: &[u8; 4]) -> bool {
4+
debug a => _1;
5+
debug b => _2;
6+
let mut _0: bool;
7+
scope 1 (inlined std::cmp::impls::<impl PartialEq for &[u8; 4]>::eq) {
8+
scope 2 (inlined array::equality::<impl PartialEq for [u8; 4]>::eq) {
9+
scope 3 (inlined <u8 as array::equality::SpecArrayEq<u8, 4>>::spec_eq) {
10+
}
11+
}
12+
}
13+
14+
bb0: {
15+
_0 = raw_eq::<[u8; 4]>(move _1, move _2) -> [return: bb1, unwind unreachable];
16+
}
17+
18+
bb1: {
19+
return;
20+
}
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// MIR for `eq_ipv6` after PreCodegen
2+
3+
fn eq_ipv6(_1: &[u16; 8], _2: &[u16; 8]) -> bool {
4+
debug a => _1;
5+
debug b => _2;
6+
let mut _0: bool;
7+
scope 1 (inlined std::cmp::impls::<impl PartialEq for &[u16; 8]>::eq) {
8+
scope 2 (inlined array::equality::<impl PartialEq for [u16; 8]>::eq) {
9+
scope 3 (inlined <u16 as array::equality::SpecArrayEq<u16, 8>>::spec_eq) {
10+
}
11+
}
12+
}
13+
14+
bb0: {
15+
_0 = raw_eq::<[u16; 8]>(move _1, move _2) -> [return: bb1, unwind unreachable];
16+
}
17+
18+
bb1: {
19+
return;
20+
}
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// MIR for `eq_ipv6` after PreCodegen
2+
3+
fn eq_ipv6(_1: &[u16; 8], _2: &[u16; 8]) -> bool {
4+
debug a => _1;
5+
debug b => _2;
6+
let mut _0: bool;
7+
scope 1 (inlined std::cmp::impls::<impl PartialEq for &[u16; 8]>::eq) {
8+
scope 2 (inlined array::equality::<impl PartialEq for [u16; 8]>::eq) {
9+
scope 3 (inlined <u16 as array::equality::SpecArrayEq<u16, 8>>::spec_eq) {
10+
}
11+
}
12+
}
13+
14+
bb0: {
15+
_0 = raw_eq::<[u16; 8]>(move _1, move _2) -> [return: bb1, unwind unreachable];
16+
}
17+
18+
bb1: {
19+
return;
20+
}
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// MIR for `eq_odd_length` after PreCodegen
2+
3+
fn eq_odd_length(_1: &[u8; 3], _2: &[u8; 3]) -> bool {
4+
debug a => _1;
5+
debug b => _2;
6+
let mut _0: bool;
7+
scope 1 (inlined std::cmp::impls::<impl PartialEq for &[u8; 3]>::eq) {
8+
scope 2 (inlined array::equality::<impl PartialEq for [u8; 3]>::eq) {
9+
scope 3 (inlined <u8 as array::equality::SpecArrayEq<u8, 3>>::spec_eq) {
10+
}
11+
}
12+
}
13+
14+
bb0: {
15+
_0 = raw_eq::<[u8; 3]>(move _1, move _2) -> [return: bb1, unwind unreachable];
16+
}
17+
18+
bb1: {
19+
return;
20+
}
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// MIR for `eq_odd_length` after PreCodegen
2+
3+
fn eq_odd_length(_1: &[u8; 3], _2: &[u8; 3]) -> bool {
4+
debug a => _1;
5+
debug b => _2;
6+
let mut _0: bool;
7+
scope 1 (inlined std::cmp::impls::<impl PartialEq for &[u8; 3]>::eq) {
8+
scope 2 (inlined array::equality::<impl PartialEq for [u8; 3]>::eq) {
9+
scope 3 (inlined <u8 as array::equality::SpecArrayEq<u8, 3>>::spec_eq) {
10+
}
11+
}
12+
}
13+
14+
bb0: {
15+
_0 = raw_eq::<[u8; 3]>(move _1, move _2) -> [return: bb1, unwind unreachable];
16+
}
17+
18+
bb1: {
19+
return;
20+
}
21+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//@ compile-flags: -O -Zmir-opt-level=2
2+
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
3+
4+
#![crate_type = "lib"]
5+
6+
// EMIT_MIR array_eq.eq_odd_length.PreCodegen.after.mir
7+
pub unsafe fn eq_odd_length<T: Copy>(a: &[u8; 3], b: &[u8; 3]) -> bool {
8+
// CHECK-LABEL: fn eq_odd_length(_1: &[u8; 3], _2: &[u8; 3]) -> bool
9+
// CHECK: _0 = raw_eq::<[u8; 3]>(move _1, move _2)
10+
a == b
11+
}
12+
13+
// EMIT_MIR array_eq.eq_ipv4.PreCodegen.after.mir
14+
pub unsafe fn eq_ipv4<T: Copy>(a: &[u8; 4], b: &[u8; 4]) -> bool {
15+
// CHECK-LABEL: fn eq_ipv4(_1: &[u8; 4], _2: &[u8; 4]) -> bool
16+
// CHECK: _0 = raw_eq::<[u8; 4]>(move _1, move _2)
17+
a == b
18+
}
19+
20+
// EMIT_MIR array_eq.eq_ipv6.PreCodegen.after.mir
21+
pub unsafe fn eq_ipv6<T: Copy>(a: &[u16; 8], b: &[u16; 8]) -> bool {
22+
// CHECK-LABEL: fn eq_ipv6(_1: &[u16; 8], _2: &[u16; 8]) -> bool
23+
// CHECK: _0 = raw_eq::<[u16; 8]>(move _1, move _2)
24+
a == b
25+
}

0 commit comments

Comments
 (0)