public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/47298] New: -O3 destroys beautifully vectorized code obtained at -O2
@ 2011-01-14 20:53 Joost.VandeVondele at pci dot uzh.ch
  2011-01-14 21:02 ` [Bug middle-end/47298] " rguenth at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: Joost.VandeVondele at pci dot uzh.ch @ 2011-01-14 20:53 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47298

           Summary: -O3 destroys beautifully vectorized code obtained at
                    -O2
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: Joost.VandeVondele@pci.uzh.ch


current trunk generates really fast vectorized code for the following testcase
(a 12x12x12 matrix multiply, c=c+a*b, benchmarked with a,b,c in cache) as can
be seen from the assembly:

> cat compare.f90
   SUBROUTINE HARD_NN_12_12_12(C,A,B) 
      REAL(KIND=8), INTENT(INOUT) :: C(12,*)
      REAL(KIND=8), INTENT(IN)    :: B(12,*), A(12,*)
      INTEGER ::i,j,l
      DO j=1,12 ; DO i=1,12; DO l=1,12
         C(i,j)=C(i,j)+A(i,l)*B(l,j)
      ENDDO ; ENDDO ; ENDDO
   END SUBROUTINE HARD_NN_12_12_12

however, this only happens with:

gfortran-trunk -O2 -funroll-loops -ftree-vectorize -ffast-math -march=corei7
-msse4.2  compare.f90

while switch -O2 to -O3 causes 'bad' code.

gfortran-trunk -O3 -funroll-loops -ftree-vectorize -ffast-math -march=corei7
-msse4.2  compare.f90

with the following tester below

-O2 runs in about 4.4s
-O3 runs in about 7.0s

> cat test_compare.f90 
      REAL(KIND=8), DIMENSION(12,12) :: A,B,C
      A=0 ; B=0 ; C=0
      DO I=1,10000000
         CALL HARD_NN_12_12_12(C,12,A,12,B,12)
      ENDDO
      END


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

end of thread, other threads:[~2013-03-27 13:02 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-14 20:53 [Bug middle-end/47298] New: -O3 destroys beautifully vectorized code obtained at -O2 Joost.VandeVondele at pci dot uzh.ch
2011-01-14 21:02 ` [Bug middle-end/47298] " rguenth at gcc dot gnu.org
2011-01-14 21:11 ` Joost.VandeVondele at pci dot uzh.ch
2011-01-14 21:27 ` Joost.VandeVondele at pci dot uzh.ch
2012-06-29 14:44 ` Joost.VandeVondele at mat dot ethz.ch
2012-06-29 15:01 ` rguenth at gcc dot gnu.org
2012-07-05  7:36 ` ebotcazou at gcc dot gnu.org
2012-07-05  8:38 ` rguenth at gcc dot gnu.org
2012-07-05  8:48 ` ebotcazou at gcc dot gnu.org
2012-07-05 10:10 ` rguenth at gcc dot gnu.org
2012-07-05 10:12 ` rguenth at gcc dot gnu.org
2012-07-05 10:30 ` ebotcazou at gcc dot gnu.org
2013-03-27 13:02 ` rguenth at gcc dot gnu.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).