------- Comment #10 from rguenther at suse dot de 2006-09-04 14:17 ------- Subject: Re: Missed optimization with power
On Mon, 4 Sep 2006, jv244 at cam dot ac dot uk wrote: > > > ------- Comment #9 from jv244 at cam dot ac dot uk 2006-09-04 14:10 ------- > (In reply to comment #7) > > Looking at how we deal with all this, we seem to like pow() very much during > > folding, even doing the reverse transformations you suggest. The > > transformation > > back to sqrt ( x**N ) with N being an integer could be done by > > expand_builtin_pow > > in case that computation of sqrt is cheap. Other than that, exposing > > integer > > powers is only a win if theres some CSE possibility. > > Despite this PR being a bit old, I'd like to add another (similar example, > also > from real code) where other compilers generate much better code: > > subroutine t(x) > x=x**1.5 > end subroutine t > > pgf90: > # lineno: 0 > sqrtss (%rdi), %xmm0 > mulss (%rdi), %xmm0 > movss %xmm0, (%rdi) > > gfortran -S -O3 -ffast-math: > movss (%rdi), %xmm0 > movq %rdi, %rbx > movss .LC0(%rip), %xmm1 > call powf > movss %xmm0, (%rbx) > popq %rbx > ret This should be doable from expand_builtin_pow if we have an optab for the sqrt computation. Richard. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25620