https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107591
--- Comment #19 from Pilar Latiesa <pilarlatiesa at gmail dot com> ---
The testcase:
#include <cmath>
struct TVec { double x, y, z; };
double dot(TVec const &u, TVec const &v)
{ return u.x * v.x + u.y * v.y + u.y * v.y + u.z * v.z; }
double mag(TVec const &u)
{ return std::sqrt(dot(u, u)); }
with current trunk is compiled as:
vmovsd 8(%rdi), %xmm0
vmovsd (%rdi), %xmm1
vmulsd %xmm0, %xmm0, %xmm0
vmovsd %xmm1, %xmm1, %xmm2
vfmadd132sd %xmm1, %xmm0, %xmm2
vmovsd 16(%rdi), %xmm1
vaddsd %xmm2, %xmm0, %xmm0
vfmadd132sd %xmm1, %xmm0, %xmm1
vsqrtsd %xmm1, %xmm1, %xmm0
ret
That's excellent. Thanks