Add a mir-opt test for == on arrays

This commit is contained in:
Scott McMurray
2026-05-10 16:53:48 -07:00
parent 4a997eeefb
commit 52ecad938e
7 changed files with 151 additions and 0 deletions
@@ -0,0 +1,21 @@
// MIR for `eq_ipv4` after PreCodegen
fn eq_ipv4(_1: &[u8; 4], _2: &[u8; 4]) -> bool {
debug a => _1;
debug b => _2;
let mut _0: bool;
scope 1 (inlined std::cmp::impls::<impl PartialEq for &[u8; 4]>::eq) {
scope 2 (inlined array::equality::<impl PartialEq for [u8; 4]>::eq) {
scope 3 (inlined <u8 as array::equality::SpecArrayEq<u8, 4>>::spec_eq) {
}
}
}
bb0: {
_0 = raw_eq::<[u8; 4]>(move _1, move _2) -> [return: bb1, unwind unreachable];
}
bb1: {
return;
}
}
@@ -0,0 +1,21 @@
// MIR for `eq_ipv4` after PreCodegen
fn eq_ipv4(_1: &[u8; 4], _2: &[u8; 4]) -> bool {
debug a => _1;
debug b => _2;
let mut _0: bool;
scope 1 (inlined std::cmp::impls::<impl PartialEq for &[u8; 4]>::eq) {
scope 2 (inlined array::equality::<impl PartialEq for [u8; 4]>::eq) {
scope 3 (inlined <u8 as array::equality::SpecArrayEq<u8, 4>>::spec_eq) {
}
}
}
bb0: {
_0 = raw_eq::<[u8; 4]>(move _1, move _2) -> [return: bb1, unwind unreachable];
}
bb1: {
return;
}
}
@@ -0,0 +1,21 @@
// MIR for `eq_ipv6` after PreCodegen
fn eq_ipv6(_1: &[u16; 8], _2: &[u16; 8]) -> bool {
debug a => _1;
debug b => _2;
let mut _0: bool;
scope 1 (inlined std::cmp::impls::<impl PartialEq for &[u16; 8]>::eq) {
scope 2 (inlined array::equality::<impl PartialEq for [u16; 8]>::eq) {
scope 3 (inlined <u16 as array::equality::SpecArrayEq<u16, 8>>::spec_eq) {
}
}
}
bb0: {
_0 = raw_eq::<[u16; 8]>(move _1, move _2) -> [return: bb1, unwind unreachable];
}
bb1: {
return;
}
}
@@ -0,0 +1,21 @@
// MIR for `eq_ipv6` after PreCodegen
fn eq_ipv6(_1: &[u16; 8], _2: &[u16; 8]) -> bool {
debug a => _1;
debug b => _2;
let mut _0: bool;
scope 1 (inlined std::cmp::impls::<impl PartialEq for &[u16; 8]>::eq) {
scope 2 (inlined array::equality::<impl PartialEq for [u16; 8]>::eq) {
scope 3 (inlined <u16 as array::equality::SpecArrayEq<u16, 8>>::spec_eq) {
}
}
}
bb0: {
_0 = raw_eq::<[u16; 8]>(move _1, move _2) -> [return: bb1, unwind unreachable];
}
bb1: {
return;
}
}
@@ -0,0 +1,21 @@
// MIR for `eq_odd_length` after PreCodegen
fn eq_odd_length(_1: &[u8; 3], _2: &[u8; 3]) -> bool {
debug a => _1;
debug b => _2;
let mut _0: bool;
scope 1 (inlined std::cmp::impls::<impl PartialEq for &[u8; 3]>::eq) {
scope 2 (inlined array::equality::<impl PartialEq for [u8; 3]>::eq) {
scope 3 (inlined <u8 as array::equality::SpecArrayEq<u8, 3>>::spec_eq) {
}
}
}
bb0: {
_0 = raw_eq::<[u8; 3]>(move _1, move _2) -> [return: bb1, unwind unreachable];
}
bb1: {
return;
}
}
@@ -0,0 +1,21 @@
// MIR for `eq_odd_length` after PreCodegen
fn eq_odd_length(_1: &[u8; 3], _2: &[u8; 3]) -> bool {
debug a => _1;
debug b => _2;
let mut _0: bool;
scope 1 (inlined std::cmp::impls::<impl PartialEq for &[u8; 3]>::eq) {
scope 2 (inlined array::equality::<impl PartialEq for [u8; 3]>::eq) {
scope 3 (inlined <u8 as array::equality::SpecArrayEq<u8, 3>>::spec_eq) {
}
}
}
bb0: {
_0 = raw_eq::<[u8; 3]>(move _1, move _2) -> [return: bb1, unwind unreachable];
}
bb1: {
return;
}
}
+25
View File
@@ -0,0 +1,25 @@
//@ compile-flags: -O -Zmir-opt-level=2
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
#![crate_type = "lib"]
// EMIT_MIR array_eq.eq_odd_length.PreCodegen.after.mir
pub unsafe fn eq_odd_length<T: Copy>(a: &[u8; 3], b: &[u8; 3]) -> bool {
// CHECK-LABEL: fn eq_odd_length(_1: &[u8; 3], _2: &[u8; 3]) -> bool
// CHECK: _0 = raw_eq::<[u8; 3]>(move _1, move _2)
a == b
}
// EMIT_MIR array_eq.eq_ipv4.PreCodegen.after.mir
pub unsafe fn eq_ipv4<T: Copy>(a: &[u8; 4], b: &[u8; 4]) -> bool {
// CHECK-LABEL: fn eq_ipv4(_1: &[u8; 4], _2: &[u8; 4]) -> bool
// CHECK: _0 = raw_eq::<[u8; 4]>(move _1, move _2)
a == b
}
// EMIT_MIR array_eq.eq_ipv6.PreCodegen.after.mir
pub unsafe fn eq_ipv6<T: Copy>(a: &[u16; 8], b: &[u16; 8]) -> bool {
// CHECK-LABEL: fn eq_ipv6(_1: &[u16; 8], _2: &[u16; 8]) -> bool
// CHECK: _0 = raw_eq::<[u16; 8]>(move _1, move _2)
a == b
}