This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Broken optimization of pow (x, 1.5) and other halfs of integers..


Hi folks.

While optimizing some of my code I replaced powf (x, 1.5f) with x * sqrt(x). Out of couriosity I checked if GCC does this optimization and found it in the code. It's in expand_builtin_pow in the file builtin.c (gcc 4.3.1 source).

However, GCC does not apply this optimization for a reason or another. If I change the constant to 3.0f I get optimized code from another special case expansion branch in that function (whole integers). Any ideas what's wrong here?


The test-code, compiled with gcc (4.3.1) test.c -funsafe-math-optimizations -O3 -S


#include <math.h>
float test (float arg)
{
 return powf (arg, 1.5f);
}

If the optimization is triggered the disassembly shouldn't have a call to _powf anymore.

Should I file a bug-report?

Cheers,
   Nils


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]