https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98429
Bug ID: 98429
Summary: Some FMA expressions are evaluated less efficiently
when -ffast-math is active
Product: gcc
Version: 10.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: chtz at informatik dot uni-bremen.de
Target Milestone: ---
If you compile an expression like
x - x*y
using fast-math optimizations it appears to get re-arranged to
x*(1-y)
which is (probably) never more efficient than the original expression,
especially if the target supports FMA operations.
Simple godbolt demonstration: https://godbolt.org/z/4q1oj9
(This is very likely not C++ specific, but I'm not sure what the correct
component is -- I also just tried this for AVX-FMA)