This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/51848] GCC is not able to vectorize when a constant value is also added to the sum of array expression inside a loop.
- From: "dominiq at lps dot ens.fr" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 13 Jan 2012 16:00:20 +0000
- Subject: [Bug middle-end/51848] GCC is not able to vectorize when a constant value is also added to the sum of array expression inside a loop.
- Auto-submitted: auto-generated
- References: <bug-51848-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51848
Dominique d'Humieres <dominiq at lps dot ens.fr> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2012-01-13
CC| |grosser at gcc dot gnu.org,
| |irar at gcc dot gnu.org
Ever Confirmed|0 |1
--- Comment #1 from Dominique d'Humieres <dominiq at lps dot ens.fr> 2012-01-13 16:00:20 UTC ---
I confirm that the loop in the codelet is not vectorized (it is if the "+1" is
removed and taken into account as "MXPx=NDX").
> but I am not sure if all that comes from vectorization alone.
Doing the above change improves the vectorization, but not the timing. One
"property" of the test air.f90 is to have several nested loops with "bad"
nesting (slow index first). I don't know if this was done to test compilers,
but if I reverse the loops manually as in
--- air.f90 2009-08-28 14:22:26.000000000 +0200
+++ air_v1.f90 2005-11-09 17:33:12.000000000 +0100
@@ -400,8 +400,8 @@
!
! COMPUTE THE FLUX TERMS
!
- DO i = 1 , MXPx
- DO j = 1 , MXPy
+ DO j = 1 , MXPy
+ DO i = 1 , MXPx
!
! compute vanleer fluxes
!
@@ -657,8 +657,8 @@
ENDDO
!
! COMPUTE THE FLUX TERMS
- DO i = 1 , MXPx
- DO j = 1 , MXPy
+ DO j = 1 , MXPy
+ DO i = 1 , MXPx
!
! compute vanleer fluxes
!
@@ -838,8 +838,8 @@
! FIND THE LOCAL TIME STEPS
!
dt = 100
- DO i = 1 , MXPx
- DO j = 1 , MXPy
+ DO j = 1 , MXPy
+ DO i = 1 , MXPx
as = DSQRT(P(i,j)/RHO(i,j)*GMA)
rdltx = RHO(i,j)*DABS(U(i,j))*ddx(i,j)/xmu(i,j)
rdlty = RHO(i,j)*DABS(V(i,j))*ddy(i,j)/xmu(i,j)
@@ -880,13 +880,13 @@
DO iy = 1 , NDY
maxy = maxy + NPY(iy) + 1
dtd = 100.0
- DO i = minx , maxx
- DO j = miny , maxy
+ DO j = miny , maxy
+ DO i = minx , maxx
IF ( dtt(i,j).LE.dtd ) dtd = dtt(i,j)
ENDDO
ENDDO
- DO i = minx , maxx
- DO j = miny , maxy
+ DO j = miny , maxy
+ DO i = minx , maxx
dtt(i,j) = dtd
ENDDO
ENDDO
@@ -958,8 +958,8 @@
con2 = 0.0
con3 = 0.0
con4 = 0.0
- DO i = 1 , MXPx
- DO j = 1 , MXPy
+ DO j = 1 , MXPy
+ DO i = 1 , MXPx
con1 = con1 + DABS(u1(i,j)-u1o(i,j))/dtt(i,j)
con2 = con2 + DABS(u2(i,j)-u2o(i,j))/dtt(i,j)
con3 = con3 + DABS(u3(i,j)-u3o(i,j))/dtt(i,j)
the timing goes from
[macbook] lin/test% time a.out > /dev/null
7.233u 0.023s 0:07.25 100.0% 0+0k 0+8io 0pf+0w
to
[macbook] lin/test% time a.out > /dev/null
6.353u 0.021s 0:06.37 100.0% 0+0k 0+8io 0pf+0w
I have made a few attempt to obtain gfortran to do these loops interchange
using graphite without success so far.