public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "dominiq at lps dot ens.fr" <gcc-bugzilla@gcc.gnu.org>
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	[thread overview]
Message-ID: <bug-51848-4-7gvoQIceWT@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <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.


  reply	other threads:[~2012-01-13 16:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-13 14:08 [Bug middle-end/51848] New: " venkataramanan.kumar at amd dot com
2012-01-13 16:02 ` dominiq at lps dot ens.fr [this message]
2012-01-15  8:49 ` [Bug middle-end/51848] " irar at il dot ibm.com
2012-01-16 10:16 ` [Bug tree-optimization/51848] " rguenth at gcc dot gnu.org
2012-07-13  9:00 ` rguenth at gcc dot gnu.org
2015-06-16 16:54 ` alalaw01 at gcc dot gnu.org
2024-02-16  8:22 ` rguenth at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-51848-4-7gvoQIceWT@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).