Auto merge of #125298 - tesuji:arrcmp, r=nikic

Add codegen test for array comparision opt

Fixed since rust 1.55
closes #62531
This commit is contained in:
bors 2024-05-21 05:55:39 +00:00
commit 1d0e4afd4c
1 changed files with 18 additions and 0 deletions

View File

@ -0,0 +1,18 @@
// Ensure the asm for array comparisons is properly optimized.
//@ compile-flags: -C opt-level=2
#![crate_type = "lib"]
// CHECK-LABEL: @compare
// CHECK: start:
// CHECK-NEXT: ret i1 true
#[no_mangle]
pub fn compare() -> bool {
let bytes = 12.5f32.to_ne_bytes();
bytes == if cfg!(target_endian = "big") {
[0x41, 0x48, 0x00, 0x00]
} else {
[0x00, 0x00, 0x48, 0x41]
}
}