https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116979

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #4)
> x86:
> 
> /app/example.cpp:6:1: note: Cost model analysis for part in loop 0:
>   Vector cost: 172
>   Scalar cost: 184
> 
> 
> 
> aarch64:
> /app/example.cpp:6:1: note: Cost model analysis for part in loop 0:
>   Vector cost: 37
>   Scalar cost: 12
> 
> So yes a cost model issue.

Note the vectorizer only does overall costing vector vs. scalar, it doesn't
cost the variant with no addsub because on the vector side that's inferior
(it would use blend).  The vectorizer doesn't see FMAs, those get introduced
later.  Backend costing would need to anticipate FMA use for scalar
costing and anticipate FMA cannot be used in the vector version.  That's
currently very difficult due to the lack of data dependence info on the
vector cost side.

If you want FMA for precision reasons you should probably use std::fma(..)
directly.

Reply via email to