Skip to content

Commit 7032c92

Browse files
committed
Add test for efficient codegen of manual eq implementations of a small struct
1 parent cd90d5c commit 7032c92

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/assembly/manual-eq-efficient.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Regression test for #106269
2+
//@ assembly-output: emit-asm
3+
//@ compile-flags: --crate-type=lib -O -C llvm-args=-x86-asm-syntax=intel
4+
//@ only-x86_64
5+
//@ ignore-sgx
6+
7+
pub struct S {
8+
a: u8,
9+
b: u8,
10+
c: u8,
11+
d: u8,
12+
}
13+
14+
// CHECK-LABEL: manual_eq:
15+
#[no_mangle]
16+
pub fn manual_eq(s1: &S, s2: &S) -> bool {
17+
// CHECK: mov [[REG:[a-z0-9]+]], dword ptr [{{[a-z0-9]+}}]
18+
// CHECK-NEXT: cmp [[REG]], dword ptr [{{[a-z0-9]+}}]
19+
// CHECK-NEXT: sete al
20+
// CHECK: ret
21+
s1.a == s2.a && s1.b == s2.b && s1.c == s2.c && s1.d == s2.d
22+
}

0 commit comments

Comments
 (0)