[Bug tree-optimization/25620] New: Missed optimisation with power
jv244 at cam dot ac dot uk
gcc-bugzilla@gcc.gnu.org
Sun Jan 1 12:29:00 GMT 2006
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
More information about the Gcc-bugs
mailing list