Skip to content

Commit 65dff32

Browse files
authored
Rollup merge of rust-lang#125298 - tesuji:arrcmp, r=nikic
Add codegen test for array comparision opt Fixed since rust 1.55 closes rust-lang#62531
2 parents 885b456 + 422de35 commit 65dff32

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/codegen/array-cmp.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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-NEXT: ret i1 true
9+
#[no_mangle]
10+
pub fn compare() -> bool {
11+
let bytes = 12.5f32.to_ne_bytes();
12+
bytes == if cfg!(target_endian = "big") {
13+
[0x41, 0x48, 0x00, 0x00]
14+
} else {
15+
[0x00, 0x00, 0x48, 0x41]
16+
}
17+
}

0 commit comments

Comments
 (0)