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: unassig...@gcc.gnu.org ReportedBy: bur...@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