public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/42694]  New: Compiler could optimize pow (x, 0.75) into sqrt (x) * sqrt (sqrt (x))
@ 2010-01-11 21:40 meissner at gcc dot gnu dot org
  2010-01-11 21:42 ` [Bug rtl-optimization/42694] " meissner at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 10+ messages in thread
From: meissner at gcc dot gnu dot org @ 2010-01-11 21:40 UTC (permalink / raw)
  To: gcc-bugs

Right now, the compiler has no special code to optimize pow (x, 0.75) into
something like sqrt (x) * sqrt (sqrt (x)) under -ffast-math, nor pow (x, 0.25)
into sqrt (sqrt (x)).  On machines with a builtin sqrt instruction, it is often
times faster to do the calculations using sqrt than calling the pow function. 
In particular, x**0.75 shows up in the bwaves spec 2006 benchmark.

For sqrt (sqrt (x)) vs pow (x, 0.25), I see:
IBM power6: 9.2 times faster
Intel core2 laptop: 5 times faster
AMD K8 system: 3.2 times faster

For sqrt (x) * sqrt (sqrt (x)) vs. pow (x, 0.75), I see:
IBM power6: 6.1 times faster
Intel core2 laptop: 3.4 times faster
AMD K8 system: 2.3 times faster

In addition, the compiler optimizes sqrt (sqrt (x)) into pow (x, 0.25), and
similar optimizations.

This should be fixed by adding a hook to say what the relative speed of sqrt
and cbrt vs. pow, so that the backend can control whether or not this
optimization should be done.  By default, the optimization is probably only
useful if -Os is used on machines that have a hardware sqrt instruction.


-- 
           Summary: Compiler could optimize pow (x, 0.75) into sqrt (x) *
                    sqrt (sqrt (x))
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: rtl-optimization
        AssignedTo: meissner at gcc dot gnu dot org
        ReportedBy: meissner at gcc dot gnu dot org
 GCC build triplet: powerpc64-unknown-linux-gnu
  GCC host triplet: powerpc64-unknown-linux-gnu
GCC target triplet: powerpc64-unknown-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42694


^ permalink raw reply	[flat|nested] 10+ messages in thread
[parent not found: <bug-42694-4@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2010-12-08 16:34 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-11 21:40 [Bug rtl-optimization/42694] New: Compiler could optimize pow (x, 0.75) into sqrt (x) * sqrt (sqrt (x)) meissner at gcc dot gnu dot org
2010-01-11 21:42 ` [Bug rtl-optimization/42694] " meissner at gcc dot gnu dot org
2010-01-12  9:08 ` [Bug middle-end/42694] " rguenth at gcc dot gnu dot org
2010-01-26  0:40 ` meissner at gcc dot gnu dot org
2010-01-26  9:57 ` rguenth at gcc dot gnu dot org
2010-01-26 10:03 ` paolo dot carlini at oracle dot com
2010-04-14 15:02 ` meissner at gcc dot gnu dot org
2010-04-14 15:03 ` meissner at gcc dot gnu dot org
     [not found] <bug-42694-4@http.gcc.gnu.org/bugzilla/>
2010-12-07 17:42 ` meissner at gcc dot gnu.org
2010-12-08 16:34 ` meissner at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).