From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17193 invoked by alias); 4 Sep 2006 14:17:51 -0000 Received: (qmail 17157 invoked by alias); 4 Sep 2006 14:17:43 -0000 Date: Mon, 04 Sep 2006 14:17:00 -0000 Message-ID: <20060904141743.17156.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug fortran/25620] Missed optimization with power In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "rguenther at suse dot de" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2006-09/txt/msg00274.txt.bz2 List-Id: ------- 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