about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLzu Tao <taolzu@gmail.com>2024-05-20 00:21:06 +0000
committerLzu Tao <taolzu@gmail.com>2024-05-21 00:09:25 +0000
commite7d6da367685ea35e11a71273da8ac6136d9243f (patch)
tree5c7472a3500bc7d7703b40d717c6c1b8afaa5215
parent698293518de49ac79eb7874e97557f8e2eabda06 (diff)
downloadrust-e7d6da367685ea35e11a71273da8ac6136d9243f.tar.gz
rust-e7d6da367685ea35e11a71273da8ac6136d9243f.zip
Add codegen test for array comparision opt
-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]
+    }
+}