about summary refs log tree commit diff
path: root/tests/codegen/array-cmp.rs
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2024-05-22 10:08:32 +0200
committerRalf Jung <post@ralfj.de>2024-05-22 10:08:32 +0200
commita1bc030b70ca9f4efdc358af222c664c3ec0b148 (patch)
tree3994ab53ef7dd1da291c7d1835dc3f7b78d0a7a4 /tests/codegen/array-cmp.rs
parent24138f003472051e1ecdc41c27748a4d0f2e511d (diff)
parentde644626c3789e62d24bb90873bdc1b41b5f6db2 (diff)
downloadrust-a1bc030b70ca9f4efdc358af222c664c3ec0b148.tar.gz
rust-a1bc030b70ca9f4efdc358af222c664c3ec0b148.zip
Merge from rustc
Diffstat (limited to 'tests/codegen/array-cmp.rs')
-rw-r--r--tests/codegen/array-cmp.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/codegen/array-cmp.rs b/tests/codegen/array-cmp.rs
new file mode 100644
index 00000000000..194c0adf1d2
--- /dev/null
+++ b/tests/codegen/array-cmp.rs
@@ -0,0 +1,18 @@
+// Ensure the asm for array comparisons is properly optimized.
+
+//@ compile-flags: -C opt-level=2
+
+#![crate_type = "lib"]
+
+// CHECK-LABEL: @compare
+// CHECK: start:
+// 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]
+    }
+}