Skip to content

Commit

Permalink
Add codegen test for array comparision opt
Browse files Browse the repository at this point in the history
  • Loading branch information
tesuji committed May 19, 2024
1 parent 6982935 commit 887246f
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/assembly/62531-array-cmp.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Ensure the asm for array comparisons is properly optimized on x86.

// min-llvm-version: 11
// assembly-output: emit-asm
// compile-flags: -C opt-level=2
// only-x86_64

#![crate_type = "lib"]

// CHECK-LABEL: compare
// CHECK: movb $1, %al
// CHECK-NEXT: retq
#[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 887246f

Please sign in to comment.