This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/25620] New: Missed optimisation with power
- From: "jv244 at cam dot ac dot uk" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 1 Jan 2006 12:29:32 -0000
- Subject: [Bug tree-optimization/25620] New: Missed optimisation with power
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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