Skip to content

Commit 887246f

Browse files
committed
Add codegen test for array comparision opt
1 parent 6982935 commit 887246f

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/assembly/62531-array-cmp.rs

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Ensure the asm for array comparisons is properly optimized on x86.
2+
3+
// min-llvm-version: 11
4+
// assembly-output: emit-asm
5+
// compile-flags: -C opt-level=2
6+
// only-x86_64
7+
8+
#![crate_type = "lib"]
9+
10+
// CHECK-LABEL: compare
11+
// CHECK: movb $1, %al
12+
// CHECK-NEXT: retq
13+
#[no_mangle]
14+
pub fn compare() -> bool {
15+
let bytes = 12.5f32.to_ne_bytes();
16+
bytes == if cfg!(target_endian = "big") {
17+
[0x41, 0x48, 0x00, 0x00]
18+
} else {
19+
[0x00, 0x00, 0x48, 0x41]
20+
}
21+
}

0 commit comments

Comments
 (0)