[Bug middle-end/57073] New: __builtin_powif (-1.0, k) should be optimized to "1.0 - 2.0 * (K%2)"
burnus at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Apr 25 18:04:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57073
Bug #: 57073
Summary: __builtin_powif (-1.0, k) should be optimized to "1.0
- 2.0 * (K%2)"
Classification: Unclassified
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: middle-end
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: burnus@gcc.gnu.org
Motivated by PR57071.
In numerical code, it is not unlike to find code of the form "(-1.0) raised to
the power of k", in Fortran: (-1.0)**k.
That translates into:
__builtin_powif (-1.0e+0, k)
which stays that way even with -O3.
Expected: It gets optimized to "1.0 - 2.0 * (K%2)"
Fortran test case:
real function f(k)
integer, value :: k
f = (-1.0)**k
end
More information about the Gcc-bugs
mailing list