https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97984
Bug ID: 97984
Summary: [10/11 Regression] Worse code for -O3 than -O2 on
aarch64 vector multiply-add
Product: gcc
Version: unknown
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: ktkachov at gcc dot gnu.org
Target Milestone: ---
Target: aarch64
The code:
void x (long * __restrict a, long * __restrict b)
{
a[0] *= b[0];
a[1] *= b[1];
a[0] += b[0];
a[1] += b[1];
}
at -O2 generates:
x:
ldp x4, x3, [x0]
ldp x2, x1, [x1]
madd x2, x2, x4, x2
madd x1, x1, x3, x1
stp x2, x1, [x0]
ret
whereas at -O3 it does:
x:
ldp x2, x3, [x0]
ldr x4, [x1]
ldr q1, [x1]
mul x2, x2, x4
ldr x4, [x1, 8]
fmov d0, x2
ins v0.d[1], x3
mul x1, x3, x4
ins v0.d[1], x1
add v0.2d, v0.2d, v1.2d
str q0, [x0]
ret
which is clearly inferior.
GCC 9 used to generate the good code for both -O2 and -O3