Skip to content

Commit e7d6da3

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

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/codegen/array-cmp.rs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Ensure the asm for array comparisons is properly optimized.
2+
3+
//@ compile-flags: -C opt-level=2
4+
5+
#![crate_type = "lib"]
6+
7+
// CHECK-LABEL: @compare
8+
// CHECK: start:
9+
// CHECK-NEXT: ret i1 true
10+
#[no_mangle]
11+
pub fn compare() -> bool {
12+
let bytes = 12.5f32.to_ne_bytes();
13+
bytes == if cfg!(target_endian = "big") {
14+
[0x41, 0x48, 0x00, 0x00]
15+
} else {
16+
[0x00, 0x00, 0x48, 0x41]
17+
}
18+
}

0 commit comments

Comments
 (0)