From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11073 invoked by alias); 13 Jan 2012 16:00:40 -0000 Received: (qmail 11054 invoked by uid 22791); 13 Jan 2012 16:00:37 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 13 Jan 2012 16:00:24 +0000 From: "dominiq at lps dot ens.fr" To: gcc-bugs@gcc.gnu.org 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. Date: Fri, 13 Jan 2012 16:02:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: dominiq at lps dot ens.fr X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Status Last reconfirmed CC Ever Confirmed Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-01/txt/msg01523.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51848 Dominique d'Humieres 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 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.