about summary refs log tree commit diff
diff options
context:
space:
mode:
authorclubby789 <jamie@hill-daniel.co.uk>2024-04-23 16:54:44 +0000
committerclubby789 <jamie@hill-daniel.co.uk>2024-04-30 13:21:08 +0000
commit7032c92b33c978c6a7c24ecca2e02ca27af23147 (patch)
tree0b39e1da5f3b4d32177a8dc71920d43f730c6c2f
parentcd90d5c03532da6f7ca7dcfb861ffabdc36a9d00 (diff)
downloadrust-7032c92b33c978c6a7c24ecca2e02ca27af23147.tar.gz
rust-7032c92b33c978c6a7c24ecca2e02ca27af23147.zip
Add test for efficient codegen of manual `eq` implementations of a small struct
-rw-r--r--tests/assembly/manual-eq-efficient.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/assembly/manual-eq-efficient.rs b/tests/assembly/manual-eq-efficient.rs
new file mode 100644
index 00000000000..817ce94f476
--- /dev/null
+++ b/tests/assembly/manual-eq-efficient.rs
@@ -0,0 +1,22 @@
+// Regression test for #106269
+//@ assembly-output: emit-asm
+//@ compile-flags: --crate-type=lib -O -C llvm-args=-x86-asm-syntax=intel
+//@ only-x86_64
+//@ ignore-sgx
+
+pub struct S {
+    a: u8,
+    b: u8,
+    c: u8,
+    d: u8,
+}
+
+// CHECK-LABEL: manual_eq:
+#[no_mangle]
+pub fn manual_eq(s1: &S, s2: &S) -> bool {
+    // CHECK: mov [[REG:[a-z0-9]+]], dword ptr [{{[a-z0-9]+}}]
+    // CHECK-NEXT: cmp [[REG]], dword ptr [{{[a-z0-9]+}}]
+    // CHECK-NEXT: sete al
+    // CHECK: ret
+    s1.a == s2.a && s1.b == s2.b && s1.c == s2.c && s1.d == s2.d
+}