public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/25620]  New: Missed optimisation with power
@ 2006-01-01 12:29 jv244 at cam dot ac dot uk
  2006-01-06 14:07 ` [Bug tree-optimization/25620] Missed optimization with power (only with -ffast-math) pinskia at gcc dot gnu dot org
                   ` (17 more replies)
  0 siblings, 18 replies; 19+ messages in thread
From: jv244 at cam dot ac dot uk @ 2006-01-01 12:29 UTC (permalink / raw)
  To: gcc-bugs

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



^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2010-03-18 14:37 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-01 12:29 [Bug tree-optimization/25620] New: Missed optimisation with power jv244 at cam dot ac dot uk
2006-01-06 14:07 ` [Bug tree-optimization/25620] Missed optimization with power (only with -ffast-math) pinskia at gcc dot gnu dot org
2006-01-13 16:37 ` [Bug tree-optimization/25620] Missed optimization with power pinskia at gcc dot gnu dot org
2006-01-13 16:44 ` [Bug fortran/25620] " rguenth at gcc dot gnu dot org
2006-01-13 17:33 ` jv244 at cam dot ac dot uk
2006-01-13 17:38 ` jv244 at cam dot ac dot uk
2006-01-13 18:15 ` jv244 at cam dot ac dot uk
2006-01-13 18:42 ` rguenth at gcc dot gnu dot org
2006-01-13 19:58 ` kargl at gcc dot gnu dot org
2006-09-04 14:10 ` jv244 at cam dot ac dot uk
2006-09-04 14:17 ` rguenther at suse dot de
2006-11-04 15:01 ` rguenth at gcc dot gnu dot org
2006-11-05 20:39 ` [Bug middle-end/25620] " patchapp at dberlin dot org
2006-11-26 14:30 ` patchapp at dberlin dot org
2006-11-27 11:39 ` rguenth at gcc dot gnu dot org
2006-11-27 11:52 ` [Bug fortran/25620] " rguenth at gcc dot gnu dot org
2006-11-27 16:49 ` jv244 at cam dot ac dot uk
2007-01-22 22:02 ` fxcoudert at gcc dot gnu dot org
2010-03-18 14:37 ` vincent at vinc17 dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).