Skip to content

Commit

Permalink
Rollup merge of rust-lang#125298 - tesuji:arrcmp, r=nikic
Browse files Browse the repository at this point in the history
Add codegen test for array comparision opt

Fixed since rust 1.55
closes rust-lang#62531
  • Loading branch information
matthiaskrgr authored May 20, 2024
2 parents 885b456 + 422de35 commit 65dff32
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/codegen/array-cmp.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Ensure the asm for array comparisons is properly optimized.

//@ compile-flags: -C opt-level=2

#![crate_type = "lib"]

// CHECK-LABEL: @compare
// 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]
}
}

0 comments on commit 65dff32

Please sign in to comment.