public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/61680] vectorization gives wrong answer for sandybridge target
       [not found] <bug-61680-4@http.gcc.gnu.org/bugzilla/>
@ 2014-07-03  9:17 ` mikpelinux at gmail dot com
  2014-07-03 10:20 ` [Bug tree-optimization/61680] [4.8/4.9/4.10 Regression] " dominiq at lps dot ens.fr
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 15+ messages in thread
From: mikpelinux at gmail dot com @ 2014-07-03  9:17 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61680

Mikael Pettersson <mikpelinux at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mikpelinux at gmail dot com

--- Comment #1 from Mikael Pettersson <mikpelinux at gmail dot com> ---
I see the exact same two results with gcc-4.10-20140629 and gcc-4.8-20140626 on
an Ivy Bridge machine.


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

* [Bug tree-optimization/61680] [4.8/4.9/4.10 Regression] vectorization gives wrong answer for sandybridge target
       [not found] <bug-61680-4@http.gcc.gnu.org/bugzilla/>
  2014-07-03  9:17 ` [Bug fortran/61680] vectorization gives wrong answer for sandybridge target mikpelinux at gmail dot com
@ 2014-07-03 10:20 ` dominiq at lps dot ens.fr
  2014-07-03 10:45 ` jakub at gcc dot gnu.org
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 15+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-07-03 10:20 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61680

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-07-03
          Component|fortran                     |tree-optimization
            Summary|vectorization gives wrong   |[4.8/4.9/4.10 Regression]
                   |answer for sandybridge      |vectorization gives wrong
                   |target                      |answer for sandybridge
                   |                            |target
     Ever confirmed|0                           |1

--- Comment #2 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Confirmed on Corei7 with '-O3 -mavx'. When compiled with revision r165415
(2010-10-13), the executable gives the expected answer, while with r165758
(2010-10-21) it gives 10.0.


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

* [Bug tree-optimization/61680] [4.8/4.9/4.10 Regression] vectorization gives wrong answer for sandybridge target
       [not found] <bug-61680-4@http.gcc.gnu.org/bugzilla/>
  2014-07-03  9:17 ` [Bug fortran/61680] vectorization gives wrong answer for sandybridge target mikpelinux at gmail dot com
  2014-07-03 10:20 ` [Bug tree-optimization/61680] [4.8/4.9/4.10 Regression] " dominiq at lps dot ens.fr
@ 2014-07-03 10:45 ` jakub at gcc dot gnu.org
  2014-07-03 10:51 ` jakub at gcc dot gnu.org
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-07-03 10:45 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61680

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
With just -mavx -O3 instead of -march=corei7-avx -O3, r165435 still works
properly, r165436 ICEs, r165599 fixed the ICE, but the result is 10.0 already.


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

* [Bug tree-optimization/61680] [4.8/4.9/4.10 Regression] vectorization gives wrong answer for sandybridge target
       [not found] <bug-61680-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2014-07-03 10:45 ` jakub at gcc dot gnu.org
@ 2014-07-03 10:51 ` jakub at gcc dot gnu.org
  2014-07-03 11:51 ` jakub at gcc dot gnu.org
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-07-03 10:51 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61680

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org
   Target Milestone|---                         |4.8.4


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

* [Bug tree-optimization/61680] [4.8/4.9/4.10 Regression] vectorization gives wrong answer for sandybridge target
       [not found] <bug-61680-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2014-07-03 10:51 ` jakub at gcc dot gnu.org
@ 2014-07-03 11:51 ` jakub at gcc dot gnu.org
  2014-07-03 12:49 ` jakub at gcc dot gnu.org
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-07-03 11:51 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61680

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
With -O3 -msse2 -fno-vect-cost-model it fails as well, so this isn't a problem
in the AVX support, just that before AVX it wasn't considered profitable to
vectorize it.


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

* [Bug tree-optimization/61680] [4.8/4.9/4.10 Regression] vectorization gives wrong answer for sandybridge target
       [not found] <bug-61680-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2014-07-03 11:51 ` jakub at gcc dot gnu.org
@ 2014-07-03 12:49 ` jakub at gcc dot gnu.org
  2014-07-03 13:28 ` jakub at gcc dot gnu.org
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-07-03 12:49 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61680

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
C testcase:
double v[4096][4];

__attribute__((noinline, noclone)) void
bar (double p[][4])
{
  int i;
  double d = __builtin_sqrt (172.0);
  for (i = 0; i < 4096; i++)
    {
      if (p[i][0] != 6.0 || p[i][1] != 6.0 || p[i][2] != 10.0)
__builtin_abort ();
      if (__builtin_fabs (p[i][3] - d) > 0.25)
__builtin_abort ();
    }
}

__attribute__((noinline, noclone)) void
foo (void)
{
  int i;
  double w[4096][4], t;
  for (i = 0; i < 4096; i++)
    {
      w[i][0] = v[i][0] + 2.0;
      w[i][1] = v[i][1] + 1.0;
      w[i][2] = v[i][2] + 4.0;
      w[i][3] = __builtin_sqrt (w[i][0] * w[i][0] + w[i][1] * w[i][1] + w[i][2]
* w[i][2]);
    }
  bar (w);
}

int
main ()
{
  int i;
  for (i = 0; i < 4096; i++)
    {
      v[i][0] = 4.0;
      v[i][1] = 5.0;
      v[i][2] = 6.0;
    }
  foo ();
  return 0;
}


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

* [Bug tree-optimization/61680] [4.8/4.9/4.10 Regression] vectorization gives wrong answer for sandybridge target
       [not found] <bug-61680-4@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2014-07-03 12:49 ` jakub at gcc dot gnu.org
@ 2014-07-03 13:28 ` jakub at gcc dot gnu.org
  2014-07-07 11:08 ` rguenth at gcc dot gnu.org
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-07-03 13:28 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61680

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I think the problem is that for the w array (in C testcase) we have first a
partial group store (stores 3 out of 4 elements), then a group load (again,
loads 3 out of 4 elements) and finally the last store of the group store.
When vectorizing the group store, we don't emit anything at all until the last
store is done, but when vectorizing the group load, we are unaware that there
is a pending group store that aliases the group load.
So, I think we need to detect the case when in between the individual group
store statements from some group there are some loads that may or must alias
the vectorizable store.  Either we can give up in that case altogether
(probably the right thing for 4.9.x and 4.8.x?), or for must alias cases
supposedly vectorization of the load could use whatever the earlier store is
storing there
(the question is why earlier loop optimizations haven't done that though, fre1
did it for some reason only for the w[i][2] store and load and not for the
other two store/load pairs.

Anyway, not familiar enough with group loads/stores to fix this, Richard, can
you please have a look?

With -O3 -msse2 -ffast-math -fno-vect-cost-model this started to be miscompiled
with r148352, supposedly pcom used to optimize the loads/stores.


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

* [Bug tree-optimization/61680] [4.8/4.9/4.10 Regression] vectorization gives wrong answer for sandybridge target
       [not found] <bug-61680-4@http.gcc.gnu.org/bugzilla/>
                   ` (6 preceding siblings ...)
  2014-07-03 13:28 ` jakub at gcc dot gnu.org
@ 2014-07-07 11:08 ` rguenth at gcc dot gnu.org
  2014-07-08  9:00 ` rguenth at gcc dot gnu.org
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-07-07 11:08 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61680

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
I'll have a look.


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

* [Bug tree-optimization/61680] [4.8/4.9/4.10 Regression] vectorization gives wrong answer for sandybridge target
       [not found] <bug-61680-4@http.gcc.gnu.org/bugzilla/>
                   ` (7 preceding siblings ...)
  2014-07-07 11:08 ` rguenth at gcc dot gnu.org
@ 2014-07-08  9:00 ` rguenth at gcc dot gnu.org
  2014-07-08 11:05 ` rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-07-08  9:00 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61680

--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> ---
Author: rguenth
Date: Tue Jul  8 08:59:17 2014
New Revision: 212348

URL: https://gcc.gnu.org/viewcvs?rev=212348&root=gcc&view=rev
Log:
2014-07-08  Richard Biener  <rguenther@suse.de>

    PR tree-optimization/61680
    * tree-vect-data-refs.c (vect_analyze_data_ref_dependence):
    Handle properly all read-write dependences with group accesses.

    * gcc.dg/vect/pr61680.c: New testcase.

Added:
    trunk/gcc/testsuite/gcc.dg/vect/pr61680.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-vect-data-refs.c


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

* [Bug tree-optimization/61680] [4.8/4.9/4.10 Regression] vectorization gives wrong answer for sandybridge target
       [not found] <bug-61680-4@http.gcc.gnu.org/bugzilla/>
                   ` (8 preceding siblings ...)
  2014-07-08  9:00 ` rguenth at gcc dot gnu.org
@ 2014-07-08 11:05 ` rguenth at gcc dot gnu.org
  2014-07-08 11:09 ` [Bug tree-optimization/61680] [4.8 " rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-07-08 11:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61680

--- Comment #10 from Richard Biener <rguenth at gcc dot gnu.org> ---
Author: rguenth
Date: Tue Jul  8 11:05:13 2014
New Revision: 212357

URL: https://gcc.gnu.org/viewcvs?rev=212357&root=gcc&view=rev
Log:
2014-07-08  Richard Biener  <rguenther@suse.de>

    PR tree-optimization/61680
    * tree-vect-data-refs.c (vect_analyze_data_ref_dependence):
    Handle properly all read-write dependences with group accesses.

    * gcc.dg/vect/pr61680.c: New testcase.

    PR tree-optimization/61681
    * tree-ssa-structalias.c (find_what_var_points_to): Expand
    NONLOCAL inside ESCAPED.

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

Added:
    branches/gcc-4_9-branch/gcc/testsuite/gcc.dg/torture/pr61681.c
    branches/gcc-4_9-branch/gcc/testsuite/gcc.dg/vect/pr61680.c
Modified:
    branches/gcc-4_9-branch/gcc/ChangeLog
    branches/gcc-4_9-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_9-branch/gcc/tree-ssa-structalias.c
    branches/gcc-4_9-branch/gcc/tree-vect-data-refs.c


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

* [Bug tree-optimization/61680] [4.8 Regression] vectorization gives wrong answer for sandybridge target
       [not found] <bug-61680-4@http.gcc.gnu.org/bugzilla/>
                   ` (9 preceding siblings ...)
  2014-07-08 11:05 ` rguenth at gcc dot gnu.org
@ 2014-07-08 11:09 ` rguenth at gcc dot gnu.org
  2014-09-09 14:03 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-07-08 11:09 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61680

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
      Known to work|                            |4.10.0, 4.9.1
            Summary|[4.8/4.9/4.10 Regression]   |[4.8 Regression]
                   |vectorization gives wrong   |vectorization gives wrong
                   |answer for sandybridge      |answer for sandybridge
                   |target                      |target
      Known to fail|                            |4.8.3, 4.9.0

--- Comment #11 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed for 4.9.1 and trunk sofar.


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

* [Bug tree-optimization/61680] [4.8 Regression] vectorization gives wrong answer for sandybridge target
       [not found] <bug-61680-4@http.gcc.gnu.org/bugzilla/>
                   ` (10 preceding siblings ...)
  2014-07-08 11:09 ` [Bug tree-optimization/61680] [4.8 " rguenth at gcc dot gnu.org
@ 2014-09-09 14:03 ` rguenth at gcc dot gnu.org
  2014-12-10 13:02 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-09-09 14:03 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61680

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|4.10.0                      |5.0

--- Comment #12 from Richard Biener <rguenth at gcc dot gnu.org> ---
For 4.8 we can't backport the patch as group analysis and dependence analysis
are still the wrong way around.  A simple

Index: gcc/tree-vect-data-refs.c
===================================================================
--- gcc/tree-vect-data-refs.c   (revision 215073)
+++ gcc/tree-vect-data-refs.c   (working copy)
@@ -2307,6 +2307,17 @@ vect_analyze_group_access (struct data_r

       while (next)
         {
+         /* Check that there is no load-store dependencies for this loads
+            to prevent a case of load-store-load to the same location.  */
+         if (GROUP_READ_WRITE_DEPENDENCE (vinfo_for_stmt (next))
+             || GROUP_READ_WRITE_DEPENDENCE (vinfo_for_stmt (prev)))
+           {
+             if (dump_enabled_p ())
+               dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, 
+                                "READ_WRITE dependence in interleaving.");
+             return false;
+           }
+
           /* Skip same data-refs.  In case that two or more stmts share
              data-ref (supported only for loads), we vectorize only the first
              stmt, and the rest get their vectorized loads from the first
@@ -2323,17 +2334,6 @@ vect_analyze_group_access (struct data_r
                   return false;
                 }

-              /* Check that there is no load-store dependencies for this loads
-                 to prevent a case of load-store-load to the same location. 
*/
-              if (GROUP_READ_WRITE_DEPENDENCE (vinfo_for_stmt (next))
-                  || GROUP_READ_WRITE_DEPENDENCE (vinfo_for_stmt (prev)))
-                {
-                  if (dump_enabled_p ())
-                    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, 
-                                     "READ_WRITE dependence in
interleaving.");
-                  return false;
-                }
-
               /* For load use the same data-ref load.  */
               GROUP_SAME_DR_STMT (vinfo_for_stmt (next)) = prev;


will regress testcases in vect.exp.

Like with two other 4.8 vectorizer miscompiles it's hard to fix them without
turning the vectorizer upside down (aka backport most of the re-org
from GCC 4.9).


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

* [Bug tree-optimization/61680] [4.8 Regression] vectorization gives wrong answer for sandybridge target
       [not found] <bug-61680-4@http.gcc.gnu.org/bugzilla/>
                   ` (11 preceding siblings ...)
  2014-09-09 14:03 ` rguenth at gcc dot gnu.org
@ 2014-12-10 13:02 ` rguenth at gcc dot gnu.org
  2014-12-19 13:34 ` jakub at gcc dot gnu.org
  2015-06-23  8:53 ` rguenth at gcc dot gnu.org
  14 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-12-10 13:02 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61680

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2


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

* [Bug tree-optimization/61680] [4.8 Regression] vectorization gives wrong answer for sandybridge target
       [not found] <bug-61680-4@http.gcc.gnu.org/bugzilla/>
                   ` (12 preceding siblings ...)
  2014-12-10 13:02 ` rguenth at gcc dot gnu.org
@ 2014-12-19 13:34 ` jakub at gcc dot gnu.org
  2015-06-23  8:53 ` rguenth at gcc dot gnu.org
  14 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-12-19 13:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61680

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.8.4                       |4.8.5

--- Comment #13 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 4.8.4 has been released.


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

* [Bug tree-optimization/61680] [4.8 Regression] vectorization gives wrong answer for sandybridge target
       [not found] <bug-61680-4@http.gcc.gnu.org/bugzilla/>
                   ` (13 preceding siblings ...)
  2014-12-19 13:34 ` jakub at gcc dot gnu.org
@ 2015-06-23  8:53 ` rguenth at gcc dot gnu.org
  14 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-06-23  8:53 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61680

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|4.8.5                       |4.9.1
      Known to fail|                            |4.8.5

--- Comment #14 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed for 4.9.1.


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

end of thread, other threads:[~2015-06-23  8:53 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-61680-4@http.gcc.gnu.org/bugzilla/>
2014-07-03  9:17 ` [Bug fortran/61680] vectorization gives wrong answer for sandybridge target mikpelinux at gmail dot com
2014-07-03 10:20 ` [Bug tree-optimization/61680] [4.8/4.9/4.10 Regression] " dominiq at lps dot ens.fr
2014-07-03 10:45 ` jakub at gcc dot gnu.org
2014-07-03 10:51 ` jakub at gcc dot gnu.org
2014-07-03 11:51 ` jakub at gcc dot gnu.org
2014-07-03 12:49 ` jakub at gcc dot gnu.org
2014-07-03 13:28 ` jakub at gcc dot gnu.org
2014-07-07 11:08 ` rguenth at gcc dot gnu.org
2014-07-08  9:00 ` rguenth at gcc dot gnu.org
2014-07-08 11:05 ` rguenth at gcc dot gnu.org
2014-07-08 11:09 ` [Bug tree-optimization/61680] [4.8 " rguenth at gcc dot gnu.org
2014-09-09 14:03 ` rguenth at gcc dot gnu.org
2014-12-10 13:02 ` rguenth at gcc dot gnu.org
2014-12-19 13:34 ` jakub at gcc dot gnu.org
2015-06-23  8:53 ` 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).