Skip to content

Commit

Permalink
Add test for efficient codegen of manual eq implementations of a sm…
Browse files Browse the repository at this point in the history
…all struct
  • Loading branch information
clubby789 committed Apr 23, 2024
1 parent cd90d5c commit 1af717d
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/assembly/manual-eq-efficient.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Regression test for #106269
//@ revisions: WIN LIN
//@ [WIN] only-windows
//@ [LIN] only-linux
//@ 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 [{{rdi|rcx}}]
// CHECK-NEXT: cmp [[REG]], dword ptr [{{rsi|rdx}}]
// CHECK-NEXT: sete al
// CHECK-NEXT: ret
s1.a == s2.a && s1.b == s2.b && s1.c == s2.c && s1.d == s2.d
}

0 comments on commit 1af717d

Please sign in to comment.