public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/52580] New: [4.8 Regression] 171.swim performance drop on x86 – vectorization doesn’t happen anymore
@ 2012-03-13 17:09 vbyakovl23 at gmail dot com
  2012-03-13 17:14 ` [Bug middle-end/52580] " burnus at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: vbyakovl23 at gmail dot com @ 2012-03-13 17:09 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 52580
           Summary: [4.8 Regression] 171.swim performance drop on x86 –
                    vectorization doesn’t happen anymore
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: vbyakovl23@gmail.com


Regression could be seen on Sandy Bridge. Change set analysis points to commit 

commit 95539e1deabbaa9dbc84b1d81ce6d0c8e7156a0f
Author: rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Fri Mar 2 14:58:55 2012 +0000

    2012-03-02  Richard Guenther  <rguenther@suse.de>

        PR tree-optimization/52406
        * tree-data-ref.h: Update documentation about DR_BASE_OBJECT.
        (struct indices): Add unconstrained_base member.
        (struct dr_alias): Remove unused vops member.
        (DR_UNCONSTRAINED_BASE): New define.
        * tree-data-ref.c (dr_analyze_indices): For COMPONENT_REFs
        add indices to allow their disambiguation.  Make DR_BASE_OBJECT
        be an artificial access that covers the whole indexed object,
        or mark it with DR_UNCONSTRAINED_BASE if we cannot do so.  Canonicalize
        plain decl base-objects to their MEM_REF variant.
        (dr_may_alias_p): When the base-object of either data reference
        has unknown size use only points-to information.
        (compute_affine_dependence): Make dumps easier to read and
        more verbose.
        * tree-vect-data-ref.c (vector_alignment_reachable_p): Use
        DR_REF when looking for packed references.
        (vect_supportable_dr_alignment): Likewise.

        * gcc.dg/torture/pr52406.c: New testcase.

    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@184789
138bc75d-0d04-0410-961f-82ee72b054a4

There are vectorizer problems. Vectorization doesn’t happened for the hottest
routines calc2() and calc3().

Command line to reproduce
gfortran -g -static -m32 -S -O3 -funroll-loops -msse2 -mfpmath=sse -ffast-math
-march=corei7 swim.f

gcc –v
Using built-in specs.
COLLECT_GCC=/gnumnt/msticlxl16_users/vbyakovl/workspaces/619/install-exp/bin/gcc
COLLECT_LTO_WRAPPER=/gnumnt/msticlxl16_users/vbyakovl/workspaces/619/install-exp/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.8.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc/configure
--prefix=/export/users/vbyakovl/workspaces/619/install-exp --disable-bootstrap
--enable-languages=c,c++,fortran CFLAGS=-g3 
Thread model: posix
gcc version 4.8.0 20120312 (experimental) (GCC)


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

* [Bug middle-end/52580] [4.8 Regression] 171.swim performance drop on x86 – vectorization doesn’t happen anymore
  2012-03-13 17:09 [Bug fortran/52580] New: [4.8 Regression] 171.swim performance drop on x86 – vectorization doesn’t happen anymore vbyakovl23 at gmail dot com
@ 2012-03-13 17:14 ` burnus at gcc dot gnu.org
  2012-03-14 10:26 ` rguenth at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-03-13 17:14 UTC (permalink / raw)
  To: gcc-bugs

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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |burnus at gcc dot gnu.org
          Component|fortran                     |middle-end
   Target Milestone|---                         |4.8.0


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

* [Bug middle-end/52580] [4.8 Regression] 171.swim performance drop on x86 – vectorization doesn’t happen anymore
  2012-03-13 17:09 [Bug fortran/52580] New: [4.8 Regression] 171.swim performance drop on x86 – vectorization doesn’t happen anymore vbyakovl23 at gmail dot com
  2012-03-13 17:14 ` [Bug middle-end/52580] " burnus at gcc dot gnu.org
@ 2012-03-14 10:26 ` rguenth at gcc dot gnu.org
  2012-03-14 14:41 ` rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-03-14 10:26 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2012-03-14
         AssignedTo|unassigned at gcc dot       |rguenth at gcc dot gnu.org
                   |gnu.org                     |
     Ever Confirmed|0                           |1

--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-03-14 09:40:54 UTC ---
I will have a look.


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

* [Bug middle-end/52580] [4.8 Regression] 171.swim performance drop on x86 – vectorization doesn’t happen anymore
  2012-03-13 17:09 [Bug fortran/52580] New: [4.8 Regression] 171.swim performance drop on x86 – vectorization doesn’t happen anymore vbyakovl23 at gmail dot com
  2012-03-13 17:14 ` [Bug middle-end/52580] " burnus at gcc dot gnu.org
  2012-03-14 10:26 ` rguenth at gcc dot gnu.org
@ 2012-03-14 14:41 ` rguenth at gcc dot gnu.org
  2012-03-14 14:55 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-03-14 14:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-03-14 14:32:49 UTC ---
Confirmed, 4.7 does

418: LOOP VECTORIZED.
398: LOOP VECTORIZED.
335: LOOP VECTORIZED.
316: LOOP VECTORIZED.
280: LOOP VECTORIZED.
262: LOOP VECTORIZED.
213: LOOP VECTORIZED.

vs.

398: LOOP VECTORIZED.
335: LOOP VECTORIZED.
213: LOOP VECTORIZED.

and different amount of alias checks as well.

For the loop at line 316 trunk cannot determine the dependence of some
refs:

316: versioning for alias required: can't determine dependence between
__BLNK__.uold[D.2769_24] and __BLNK__.vnew[D.2782_49]

Reduced testcase:

      SUBROUTINE CALC2
      IMPLICIT REAL*8   (A-H, O-Z)
      PARAMETER (N1=1335, N2=1335)

      COMMON  U(N1,N2), V(N1,N2), P(N1,N2),
     *        UNEW(N1,N2), VNEW(N1,N2),
     1        PNEW(N1,N2), UOLD(N1,N2),
     *        VOLD(N1,N2), POLD(N1,N2),
     2        CU(N1,N2), CV(N1,N2),
     *        Z(N1,N2), H(N1,N2), PSI(N1,N2)
      COMMON /CONS/ DT,TDT,DX,DY,A,ALPHA,ITMAX,MPRINT,M,N,MP1,
     1              NP1,EL,PI,TPI,DI,DJ,PCF
      TDTS8 = TDT/8.D0
      TDTSDX = TDT/DX
      TDTSDY = TDT/DY

      DO 200 J=1,N
      DO 200 I=1,M
      UNEW(I+1,J) = UOLD(I+1,J)+
     1    TDTS8*(Z(I+1,J+1)+Z(I+1,J))*(CV(I+1,J+1)+CV(I,J+1)+CV(I,J)
     2       +CV(I+1,J))-TDTSDX*(H(I+1,J)-H(I,J))
      VNEW(I,J+1) = VOLD(I,J+1)-TDTS8*(Z(I+1,J+1)+Z(I,J+1))
     1       *(CU(I+1,J+1)+CU(I,J+1)+CU(I,J)+CU(I+1,J))
     2       -TDTSDY*(H(I,J+1)-H(I,J))
      PNEW(I,J) = POLD(I,J)-TDTSDX*(CU(I+1,J)-CU(I,J))
     1       -TDTSDY*(CV(I,J+1)-CV(I,J))
  200 CONTINUE
      RETURN
      END


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

* [Bug middle-end/52580] [4.8 Regression] 171.swim performance drop on x86 – vectorization doesn’t happen anymore
  2012-03-13 17:09 [Bug fortran/52580] New: [4.8 Regression] 171.swim performance drop on x86 – vectorization doesn’t happen anymore vbyakovl23 at gmail dot com
                   ` (2 preceding siblings ...)
  2012-03-14 14:41 ` rguenth at gcc dot gnu.org
@ 2012-03-14 14:55 ` rguenth at gcc dot gnu.org
  2012-03-15 10:07 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-03-14 14:55 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-03-14 14:52:11 UTC ---
The issue is that with the artificial access functions added for
__BLNK__.uold and __BLK__.vnew we run the subscript dependence tester
but that fails even when only a single access function cannot be
analyzed.

The following fixes that.

Index: gcc/tree-data-ref.c
===================================================================
--- gcc/tree-data-ref.c (revision 185379)
+++ gcc/tree-data-ref.c (working copy)
@@ -3460,6 +3460,7 @@ subscript_dependence_tester_1 (struct da
   unsigned int i;
   tree last_conflicts;
   struct subscript *subscript;
+  tree res = NULL_TREE;

   for (i = 0; VEC_iterate (subscript_p, DDR_SUBSCRIPTS (ddr), i, subscript);
        i++)
@@ -3471,40 +3472,43 @@ subscript_dependence_tester_1 (struct da
                                      &overlaps_a, &overlaps_b,
                                      &last_conflicts, loop_nest);

+      if (SUB_CONFLICTS_IN_A (subscript))
+       free_conflict_function (SUB_CONFLICTS_IN_A (subscript));
+      if (SUB_CONFLICTS_IN_B (subscript))
+       free_conflict_function (SUB_CONFLICTS_IN_B (subscript));
+
+      SUB_CONFLICTS_IN_A (subscript) = overlaps_a;
+      SUB_CONFLICTS_IN_B (subscript) = overlaps_b;
+      SUB_LAST_CONFLICT (subscript) = last_conflicts;
+
+      /* If there is any undetermined conflict function we have to
+         give a conservative answer in case we cannot prove that
+        no dependence exists when analyzing another subscript.  */
       if (CF_NOT_KNOWN_P (overlaps_a)
          || CF_NOT_KNOWN_P (overlaps_b))
        {
-         finalize_ddr_dependent (ddr, chrec_dont_know);
-         dependence_stats.num_dependence_undetermined++;
-         free_conflict_function (overlaps_a);
-         free_conflict_function (overlaps_b);
-         return false;
+         res = chrec_dont_know;
+         continue;
        }

+      /* When there is a subscript with no dependence we can stop.  */
       else if (CF_NO_DEPENDENCE_P (overlaps_a)
               || CF_NO_DEPENDENCE_P (overlaps_b))
        {
-         finalize_ddr_dependent (ddr, chrec_known);
-         dependence_stats.num_dependence_independent++;
-         free_conflict_function (overlaps_a);
-         free_conflict_function (overlaps_b);
-         return false;
-       }
-
-      else
-       {
-         if (SUB_CONFLICTS_IN_A (subscript))
-           free_conflict_function (SUB_CONFLICTS_IN_A (subscript));
-         if (SUB_CONFLICTS_IN_B (subscript))
-           free_conflict_function (SUB_CONFLICTS_IN_B (subscript));
-
-         SUB_CONFLICTS_IN_A (subscript) = overlaps_a;
-         SUB_CONFLICTS_IN_B (subscript) = overlaps_b;
-         SUB_LAST_CONFLICT (subscript) = last_conflicts;
+         res = chrec_known;
+         break;
        }
     }

-  return true;
+  if (res == NULL_TREE)
+    return true;
+
+  if (res == chrec_known)
+    dependence_stats.num_dependence_independent++;
+  else
+    dependence_stats.num_dependence_undetermined++;
+  finalize_ddr_dependent (ddr, res);
+  return false;
 }

 /* Computes the conflicting iterations in LOOP_NEST, and initialize DDR.  */


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

* [Bug middle-end/52580] [4.8 Regression] 171.swim performance drop on x86 – vectorization doesn’t happen anymore
  2012-03-13 17:09 [Bug fortran/52580] New: [4.8 Regression] 171.swim performance drop on x86 – vectorization doesn’t happen anymore vbyakovl23 at gmail dot com
                   ` (3 preceding siblings ...)
  2012-03-14 14:55 ` rguenth at gcc dot gnu.org
@ 2012-03-15 10:07 ` rguenth at gcc dot gnu.org
  2012-03-15 10:37 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-03-15 10:07 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-03-15 10:04:59 UTC ---
Author: rguenth
Date: Thu Mar 15 10:04:55 2012
New Revision: 185426

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=185426
Log:
2012-03-15  Richard Guenther  <rguenther@suse.de>

    PR middle-end/52580
    * tree-data-ref.c (subscript_dependence_tester_1): Check
    all dimensions for non-conflicting access functions.

    * gfortran.dg/vect/pr52580.f: New testcase.

Added:
    trunk/gcc/testsuite/gfortran.dg/vect/pr52580.f
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-data-ref.c


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

* [Bug middle-end/52580] [4.8 Regression] 171.swim performance drop on x86 – vectorization doesn’t happen anymore
  2012-03-13 17:09 [Bug fortran/52580] New: [4.8 Regression] 171.swim performance drop on x86 – vectorization doesn’t happen anymore vbyakovl23 at gmail dot com
                   ` (4 preceding siblings ...)
  2012-03-15 10:07 ` rguenth at gcc dot gnu.org
@ 2012-03-15 10:37 ` rguenth at gcc dot gnu.org
  2012-03-15 13:30 ` vbyakovl23 at gmail dot com
  2012-04-03 13:07 ` rguenth at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-03-15 10:37 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
             Blocks|                            |52406
         Resolution|                            |FIXED

--- Comment #5 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-03-15 10:05:32 UTC ---
Fixed.


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

* [Bug middle-end/52580] [4.8 Regression] 171.swim performance drop on x86 – vectorization doesn’t happen anymore
  2012-03-13 17:09 [Bug fortran/52580] New: [4.8 Regression] 171.swim performance drop on x86 – vectorization doesn’t happen anymore vbyakovl23 at gmail dot com
                   ` (5 preceding siblings ...)
  2012-03-15 10:37 ` rguenth at gcc dot gnu.org
@ 2012-03-15 13:30 ` vbyakovl23 at gmail dot com
  2012-04-03 13:07 ` rguenth at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: vbyakovl23 at gmail dot com @ 2012-03-15 13:30 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Vladimir Yakovlev <vbyakovl23 at gmail dot com> 2012-03-15 12:53:50 UTC ---
I checked the fix gives 21% acceleration of 171.swim on Sundy Bridge. Thanks.


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

* [Bug middle-end/52580] [4.8 Regression] 171.swim performance drop on x86 – vectorization doesn’t happen anymore
  2012-03-13 17:09 [Bug fortran/52580] New: [4.8 Regression] 171.swim performance drop on x86 – vectorization doesn’t happen anymore vbyakovl23 at gmail dot com
                   ` (6 preceding siblings ...)
  2012-03-15 13:30 ` vbyakovl23 at gmail dot com
@ 2012-04-03 13:07 ` rguenth at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-04-03 13:07 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-04-03 13:06:03 UTC ---
Author: rguenth
Date: Tue Apr  3 13:05:58 2012
New Revision: 186107

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=186107
Log:
2012-04-03  Richard Guenther  <rguenther@suse.de>

    Backport from mainline
    2012-03-15  Richard Guenther  <rguenther@suse.de>

    PR middle-end/52580
    * tree-data-ref.c (subscript_dependence_tester_1): Check
    all dimensions for non-conflicting access functions.

    * gfortran.dg/vect/pr52580.f: New testcase.

Added:
    branches/gcc-4_7-branch/gcc/testsuite/gfortran.dg/vect/pr52580.f
Modified:
    branches/gcc-4_7-branch/gcc/ChangeLog
    branches/gcc-4_7-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_7-branch/gcc/tree-data-ref.c


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

end of thread, other threads:[~2012-04-03 13:07 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-13 17:09 [Bug fortran/52580] New: [4.8 Regression] 171.swim performance drop on x86 – vectorization doesn’t happen anymore vbyakovl23 at gmail dot com
2012-03-13 17:14 ` [Bug middle-end/52580] " burnus at gcc dot gnu.org
2012-03-14 10:26 ` rguenth at gcc dot gnu.org
2012-03-14 14:41 ` rguenth at gcc dot gnu.org
2012-03-14 14:55 ` rguenth at gcc dot gnu.org
2012-03-15 10:07 ` rguenth at gcc dot gnu.org
2012-03-15 10:37 ` rguenth at gcc dot gnu.org
2012-03-15 13:30 ` vbyakovl23 at gmail dot com
2012-04-03 13:07 ` 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).