From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16083 invoked by alias); 1 Jan 2006 12:29:34 -0000 Received: (qmail 16071 invoked by uid 48); 1 Jan 2006 12:29:32 -0000 Date: Sun, 01 Jan 2006 12:29:00 -0000 Subject: [Bug tree-optimization/25620] New: Missed optimisation with power X-Bugzilla-Reason: CC Message-ID: 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-01/txt/msg00081.txt.bz2 List-Id: The following is not optimised (I tested current 4.2) with -ffast-math -O2 (or any of the other options I tried): SUBROUTINE S41(a,b,c,N) IMPLICIT NONE integer :: N real*8 :: a(N),b(N),c(N) integer :: i c=0.0D0 DO i=1,N b(i)=b(i)+a(i)**(4.0D0/3.0D0) c(i)=c(i)+a(i)**(2.0D0/3.0D0) ENDDO END SUBROUTINE This could be written as SUBROUTINE S42(a,b,c,N) IMPLICIT NONE integer :: N real*8 :: a(N),b(N),c(N),tmp,tmp2,tmp4 real*8, parameter :: p=1.0D0/3.0D0 integer :: i c=0.0D0 DO i=1,N tmp=a(i)**p ! could even be done with a cube root tmp2=tmp*tmp tmp4=tmp2*tmp2 b(i)=b(i)+tmp4 c(i)=c(i)+tmp2 ENDDO END SUBROUTINE saving at least one expensive power computation. Also replacing the cube root with specific code would be nice. -- Summary: Missed optimisation with power Product: gcc Version: 4.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jv244 at cam dot ac dot uk http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25620