From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13064 invoked by alias); 4 Sep 2006 14:10:43 -0000 Received: (qmail 12948 invoked by uid 48); 4 Sep 2006 14:10:34 -0000 Date: Mon, 04 Sep 2006 14:10:00 -0000 Message-ID: <20060904141034.12947.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: "jv244 at cam dot ac dot uk" 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/msg00272.txt.bz2 List-Id: ------- 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 trying to time this with the following fragment: y=0. DO i=1,10000000 x=i y=y+x**1.5 ENDDO write(6,*) y END pgf90 is about 10 times faster than gfortran -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25620