Closed
Description
Consider the following test case.
https://godbolt.org/z/Ecd865P97
#include <cmath>
double f1() {
return std::sinh(0.);
}
double f2() {
return std::cosh(0.);
}
double f3() {
return std::tanh(0.);
}
The optimization results for std::sinh(0.)
, std::cosh(0.)
, and std::tanh(0.)
differ between -O1
and -O1 -ffast-math
. Specifically, when -ffast-math
is enabled, sinh(0.)
and cosh(0.)
are not folded into constants but instead call the corresponding library functions. This suggests that -ffast-math
is restricting optimization rather than enhancing it.