[Bug optimization/15187] Inefficient if optimization with -O2 -ffast-math
uros at kss-loka dot si
gcc-bugzilla@gcc.gnu.org
Wed Apr 28 11:22:00 GMT 2004
------- Additional Comments From uros at kss-loka dot si 2004-04-28 09:52 -------
Yes, fsincos would be the best solution in particular case, when both sin() and
cos() are involved. However with more general testcase, for example:
double test(double x) {
if (x > 0.0)
return x + 1.0;
else
return sqrt(x); // or sin(x), cos(x), etc...
}
square root is _always_ called, even if x > 0.0. If we return sin(x) [which
could not be combine with sqrt in any way] instead of (x + 1.0), both sin() and
sqrt() will be called when x > 0.0. In this case, -march=i686 (which has cmov
instruction) will produce code, which will _always_ call sin() and sqrt() and
then cmov will pick one of the results. When fsqrt x87 instruction takes 70
cycles and fsin x87 insn takes 65-100 cycles to execute, this is not a win in
any case.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15187
More information about the Gcc-bugs
mailing list