Skip to content

Commit 1af717d

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

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/assembly/manual-eq-efficient.rs

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

0 commit comments

Comments
 (0)