public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/101445] New: wrong code at -O3 on x86_64-linux-gnu
@ 2021-07-14  2:50 qrzhang at gatech dot edu
  2021-07-14  2:50 ` [Bug tree-optimization/101445] " qrzhang at gatech dot edu
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: qrzhang at gatech dot edu @ 2021-07-14  2:50 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 101445
           Summary: wrong code at -O3 on x86_64-linux-gnu
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: qrzhang at gatech dot edu
  Target Milestone: ---

It appears to be a recent regression. Note that -O2 works fine.

$ gcc-trunk -v
Supported LTO compression algorithms: zlib
gcc version 12.0.0 20210713 (experimental) [master revision
7670b6633e5:d2f95d2ac56:1583b8bff0be7e41aa721dde79f90ca0763bd4e2] (GCC)


$ gcc-trunk abc.c ; ./a.out
0
0
0
0
0
0
0



$ gcc-trunk -O3 abc.c ; ./a.out
0
0
3
0
0
0
0



$ cat abc.c
int a[35] = {1, 1, 3};
char b = 4;
int c, d;
int main() {
  char e;
  for (; b >= 0; b--) {
    e = 3;
    for (; e >= 0; e--)
      a[b * 5 + e] = a[b * 5 + e + 1];
  }
  for (; c < 5; c++)
    ;
  for (; d < 7; d++)
    printf("%d\n", a[c * d]);
}

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

* [Bug tree-optimization/101445] wrong code at -O3 on x86_64-linux-gnu
  2021-07-14  2:50 [Bug tree-optimization/101445] New: wrong code at -O3 on x86_64-linux-gnu qrzhang at gatech dot edu
@ 2021-07-14  2:50 ` qrzhang at gatech dot edu
  2021-07-14  2:58 ` [Bug tree-optimization/101445] [11/12 Regression] " pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: qrzhang at gatech dot edu @ 2021-07-14  2:50 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Qirun Zhang <qrzhang at gatech dot edu> ---
My bisection points to g:f75211822f8d84bb706421d3692e

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

* [Bug tree-optimization/101445] [11/12 Regression] wrong code at -O3 on x86_64-linux-gnu
  2021-07-14  2:50 [Bug tree-optimization/101445] New: wrong code at -O3 on x86_64-linux-gnu qrzhang at gatech dot edu
  2021-07-14  2:50 ` [Bug tree-optimization/101445] " qrzhang at gatech dot edu
@ 2021-07-14  2:58 ` pinskia at gcc dot gnu.org
  2021-07-14  6:12 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-14  2:58 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|wrong code at -O3 on        |[11/12 Regression] wrong
                   |x86_64-linux-gnu            |code at -O3 on
                   |                            |x86_64-linux-gnu
             Target|                            |x86_64-linux-gnu
   Target Milestone|---                         |11.2
            Version|unknown                     |11.1.0
           Keywords|                            |wrong-code

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Qirun Zhang from comment #1)

r11-1897

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

* [Bug tree-optimization/101445] [11/12 Regression] wrong code at -O3 on x86_64-linux-gnu
  2021-07-14  2:50 [Bug tree-optimization/101445] New: wrong code at -O3 on x86_64-linux-gnu qrzhang at gatech dot edu
  2021-07-14  2:50 ` [Bug tree-optimization/101445] " qrzhang at gatech dot edu
  2021-07-14  2:58 ` [Bug tree-optimization/101445] [11/12 Regression] " pinskia at gcc dot gnu.org
@ 2021-07-14  6:12 ` rguenth at gcc dot gnu.org
  2021-07-14  8:58 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-07-14  6:12 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2
   Last reconfirmed|                            |2021-07-14
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
I will have a look.

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

* [Bug tree-optimization/101445] [11/12 Regression] wrong code at -O3 on x86_64-linux-gnu
  2021-07-14  2:50 [Bug tree-optimization/101445] New: wrong code at -O3 on x86_64-linux-gnu qrzhang at gatech dot edu
                   ` (2 preceding siblings ...)
  2021-07-14  6:12 ` rguenth at gcc dot gnu.org
@ 2021-07-14  8:58 ` rguenth at gcc dot gnu.org
  2021-07-14 10:31 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-07-14  8:58 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
Simplified testcase, fails at -O2 -ftree-loop-vectorize

int a[35] = {1, 1, 3};
void __attribute__((noipa))
foo ()
{
  for (int b = 4; b >= 0; b--)
    { 
      int tem = a[b * 5 + 3 + 1];
      a[b * 5 + 3] = tem;
      a[b * 5 + 2] = tem;
      a[b * 5 + 1] = tem;
      a[b * 5 + 0] = tem;
    }
}
int main()
{
  foo ();
  for (int d = 0; d < 25; d++)
    if (a[d] != 0)
      __builtin_abort ();
  return 0;
}

the load is vectorized in an odd way, but "correct" - but the final IV
update(s)
are bogus.

  <bb 2>
  vectp_a.7_34 = &a + 84;  // &a[21]

  <bb 3>
  # vectp_a.6_35 = PHI <vectp_a.6_36(5), vectp_a.7_34(2)>
...
  vect_tem_9.8_37 = MEM <vector(4) int> [(int *)vectp_a.6_35];
  vect_tem_9.9_38 = VEC_PERM_EXPR <vect_tem_9.8_37, vect_tem_9.8_37, { 3, 2, 1,
0 }>;
  vectp_a.6_39 = vectp_a.6_35 + 18446744073709551600;  // -16
  vect_tem_9.10_40 = MEM <vector(4) int> [(int *)vectp_a.6_39];
  vect_tem_9.11_41 = VEC_PERM_EXPR <vect_tem_9.10_40, vect_tem_9.10_40, { 3, 2,
1, 0 }>;
  vectp_a.6_42 = vectp_a.6_39 + 18446744073709551604;  // -12
  vect_tem_9.12_43 = VEC_PERM_EXPR <vect_tem_9.9_38, vect_tem_9.9_38, { 0, 0,
0, 0 }>;
...
  vectp_a.6_36 = vectp_a.6_42 + 18446744073709551600;  // -16

we're doing VMAT_CONTIGUOUS_REVERSE but the group has gaps and we fail to
account for the reverse when computing group_gap_adj (which should have been
+12, not -12).

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

* [Bug tree-optimization/101445] [11/12 Regression] wrong code at -O3 on x86_64-linux-gnu
  2021-07-14  2:50 [Bug tree-optimization/101445] New: wrong code at -O3 on x86_64-linux-gnu qrzhang at gatech dot edu
                   ` (3 preceding siblings ...)
  2021-07-14  8:58 ` rguenth at gcc dot gnu.org
@ 2021-07-14 10:31 ` cvs-commit at gcc dot gnu.org
  2021-07-14 11:09 ` cvs-commit at gcc dot gnu.org
  2021-07-14 11:09 ` rguenth at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-07-14 10:31 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:a967a3efd39280fe3f5774e45490e991f8e99059

commit r12-2294-ga967a3efd39280fe3f5774e45490e991f8e99059
Author: Richard Biener <rguenther@suse.de>
Date:   Wed Jul 14 11:06:58 2021 +0200

    tree-optimization/101445 - fix negative stride SLP vect with gaps

    The following fixes the IV adjustment for the gap in a negative
    stride SLP vectorization.  The adjustment was in the wrong direction,
    now fixes as in the patch.

    2021-07-14  Richard Biener  <rguenther@suse.de>

            PR tree-optimization/101445
            * tree-vect-stmts.c (vectorizable_load): Do the gap adjustment
            of the IV in the correct direction for negative stride
            accesses.

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

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

* [Bug tree-optimization/101445] [11/12 Regression] wrong code at -O3 on x86_64-linux-gnu
  2021-07-14  2:50 [Bug tree-optimization/101445] New: wrong code at -O3 on x86_64-linux-gnu qrzhang at gatech dot edu
                   ` (4 preceding siblings ...)
  2021-07-14 10:31 ` cvs-commit at gcc dot gnu.org
@ 2021-07-14 11:09 ` cvs-commit at gcc dot gnu.org
  2021-07-14 11:09 ` rguenth at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-07-14 11:09 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Richard Biener
<rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:1eee5fa556432fb6eab3a479c95609c5f3791ccb

commit r11-8736-g1eee5fa556432fb6eab3a479c95609c5f3791ccb
Author: Richard Biener <rguenther@suse.de>
Date:   Wed Jul 14 11:06:58 2021 +0200

    tree-optimization/101445 - fix negative stride SLP vect with gaps

    The following fixes the IV adjustment for the gap in a negative
    stride SLP vectorization.  The adjustment was in the wrong direction,
    now fixes as in the patch.

    2021-07-14  Richard Biener  <rguenther@suse.de>

            PR tree-optimization/101445
            * tree-vect-stmts.c (vectorizable_load): Do the gap adjustment
            of the IV in the correct direction for negative stride
            accesses.

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

    (cherry picked from commit a967a3efd39280fe3f5774e45490e991f8e99059)

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

* [Bug tree-optimization/101445] [11/12 Regression] wrong code at -O3 on x86_64-linux-gnu
  2021-07-14  2:50 [Bug tree-optimization/101445] New: wrong code at -O3 on x86_64-linux-gnu qrzhang at gatech dot edu
                   ` (5 preceding siblings ...)
  2021-07-14 11:09 ` cvs-commit at gcc dot gnu.org
@ 2021-07-14 11:09 ` rguenth at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-07-14 11:09 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
      Known to fail|                            |11.1.0
             Status|ASSIGNED                    |RESOLVED
      Known to work|                            |11.1.1, 12.0

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

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

end of thread, other threads:[~2021-07-14 11:09 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-14  2:50 [Bug tree-optimization/101445] New: wrong code at -O3 on x86_64-linux-gnu qrzhang at gatech dot edu
2021-07-14  2:50 ` [Bug tree-optimization/101445] " qrzhang at gatech dot edu
2021-07-14  2:58 ` [Bug tree-optimization/101445] [11/12 Regression] " pinskia at gcc dot gnu.org
2021-07-14  6:12 ` rguenth at gcc dot gnu.org
2021-07-14  8:58 ` rguenth at gcc dot gnu.org
2021-07-14 10:31 ` cvs-commit at gcc dot gnu.org
2021-07-14 11:09 ` cvs-commit at gcc dot gnu.org
2021-07-14 11:09 ` 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).