https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122261
Bug ID: 122261
Summary: Missed vectorisation with wrapper struct
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Keywords: alias, missed-optimization
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: sjames at gcc dot gnu.org
Target Milestone: ---
This comes from https://github.com/llvm/llvm-project/issues/54646:
```
#ifdef FOO
struct S { long int a; long int b; };
void f(S& s1, const S& s2 ) {
s1.a = s2.a;
s1.b = s2.b;
}
#else
struct Wrapper { long int t; };
struct S1 { Wrapper a; Wrapper b; };
void f(S1& s1, const S1& s2 ) {
s1.a = s2.a;
s1.b = s2.b;
}
#endif
```
At -O2 on trunk (with -UFOO; -DFOO is fine), we get:
```
"f(S1&, S1 const&)":
mov rax, QWORD PTR [rsi]
mov QWORD PTR [rdi], rax
mov rax, QWORD PTR [rsi+8]
mov QWORD PTR [rdi+8], rax
ret
```
Clang with -O2 -Xclang -new-struct-path-tbaa gives:
```
f(S1&, S1 const&):
movups xmm0, xmmword ptr [rsi]
movups xmmword ptr [rdi], xmm0
ret
```