public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/103995] New: conj() ignored with tree loop vectorizer
@ 2022-01-12 17:47 michelemartone at users dot sourceforge.net
  2022-01-12 17:59 ` [Bug tree-optimization/103995] " michelemartone at users dot sourceforge.net
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: michelemartone at users dot sourceforge.net @ 2022-01-12 17:47 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 103995
           Summary: conj() ignored with tree loop vectorizer
           Product: gcc
           Version: 11.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: michelemartone at users dot sourceforge.net
  Target Milestone: ---

Created attachment 52173
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52173&action=edit
conj() ignored with tree loop vectorizer -- reproducer

Hi.

With gcc-11.2.0 on x86-64 and given certain flags, this program (see
attachment) computes wrong results.                                             
Specifically, it seems like a conj() is being ignored in a loop.
The buggy.c file contains the impacted function, but also a reference one;
their results are being compared in main.c.

Reproduces on arch x86-64 with 11.2.0 with:

        gcc -c -O3 buggy.c && gcc -c -O0 main.c && gcc buggy.o main.o -o buggy
&& ./buggy

Using ASAN:

        gcc -c -O3 -fsanitize=address -fno-omit-frame-pointer buggy.c && gcc -c
-O3 -fsanitize=address -fno-omit-frame-pointer main.c && gcc buggy.o -lasan
main.o -o buggy && ./buggy   

it does not reproduce.

Reproducer flags with lower optimization are:

        gcc -c -O1 -ftree-loop-vectorize -ftree-slp-vectorize buggy.c && gcc -c
-O0 main.c && gcc -O0 buggy.o main.o -o buggy && ./buggy

This can be minimized further by deactivating the individual -O1 flags listed
on

https://gcc.gnu.org/onlinedocs/gcc-11.2.0/gcc/Optimize-Options.html#index-ftree-dse
using (-fno-...), exception made for two flags: -ftree-ch and -ftree-forwprop.

Using:  

        -O0 -ftree-ch -ftree-forwprop -ftree-loop-vectorize
-ftree-slp-vectorize

is not enough -- seems like some implicit -O1 option is needed.

Putting all the code in one file does not reproduce the problem.

The Makefile has a recipe building and running the program with decreasing
optimization level, stepwise.

        make # will print BUG on mismatch, OK otherwise; make expected NOT to
fail on gcc-11.2.0

        make dist # zip the whole
        make clean # clean

It does not reproduce on x86-64 and 10.2.0.
On aarch64 tried only with 11.0.0 and it does not reproduce.

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

* [Bug tree-optimization/103995] conj() ignored with tree loop vectorizer
  2022-01-12 17:47 [Bug tree-optimization/103995] New: conj() ignored with tree loop vectorizer michelemartone at users dot sourceforge.net
@ 2022-01-12 17:59 ` michelemartone at users dot sourceforge.net
  2022-01-12 19:17 ` [Bug tree-optimization/103995] [11/12 Regression] " pinskia at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: michelemartone at users dot sourceforge.net @ 2022-01-12 17:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Michele Martone <michelemartone at users dot sourceforge.net> ---
Small correction: the URL in the link above should have been just
 https://gcc.gnu.org/onlinedocs/gcc-11.2.0/gcc/Optimize-Options.html
(top of the page).

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

* [Bug tree-optimization/103995] [11/12 Regression] conj() ignored with tree loop vectorizer
  2022-01-12 17:47 [Bug tree-optimization/103995] New: conj() ignored with tree loop vectorizer michelemartone at users dot sourceforge.net
  2022-01-12 17:59 ` [Bug tree-optimization/103995] " michelemartone at users dot sourceforge.net
@ 2022-01-12 19:17 ` pinskia at gcc dot gnu.org
  2022-01-12 22:12 ` michelemartone at users dot sourceforge.net
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-12 19:17 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|conj() ignored with tree    |[11/12 Regression] conj()
                   |loop vectorizer             |ignored with tree loop
                   |                            |vectorizer
             Target|                            |x86-64
   Target Milestone|---                         |11.3
      Known to work|                            |10.2.0
      Known to fail|                            |11.2.0

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

* [Bug tree-optimization/103995] [11/12 Regression] conj() ignored with tree loop vectorizer
  2022-01-12 17:47 [Bug tree-optimization/103995] New: conj() ignored with tree loop vectorizer michelemartone at users dot sourceforge.net
  2022-01-12 17:59 ` [Bug tree-optimization/103995] " michelemartone at users dot sourceforge.net
  2022-01-12 19:17 ` [Bug tree-optimization/103995] [11/12 Regression] " pinskia at gcc dot gnu.org
@ 2022-01-12 22:12 ` michelemartone at users dot sourceforge.net
  2022-01-12 22:13 ` michelemartone at users dot sourceforge.net
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: michelemartone at users dot sourceforge.net @ 2022-01-12 22:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Michele Martone <michelemartone at users dot sourceforge.net> ---
Created attachment 52175
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52175&action=edit
output by running 'make'

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

* [Bug tree-optimization/103995] [11/12 Regression] conj() ignored with tree loop vectorizer
  2022-01-12 17:47 [Bug tree-optimization/103995] New: conj() ignored with tree loop vectorizer michelemartone at users dot sourceforge.net
                   ` (2 preceding siblings ...)
  2022-01-12 22:12 ` michelemartone at users dot sourceforge.net
@ 2022-01-12 22:13 ` michelemartone at users dot sourceforge.net
  2022-01-13  8:05 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: michelemartone at users dot sourceforge.net @ 2022-01-12 22:13 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Michele Martone <michelemartone at users dot sourceforge.net> ---
Comment on attachment 52175
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52175
output by running 'make'

For reference, I add here the output of 'make' with the defect.
The program is being built and run with different flags (also clang, for
comparison).
Each run ends with a line beginning either with 'OK' or 'BUG'.
One can see in the 'BUG' cases, '(0 -12)' is being computed in place of '(12
0)'.

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

* [Bug tree-optimization/103995] [11/12 Regression] conj() ignored with tree loop vectorizer
  2022-01-12 17:47 [Bug tree-optimization/103995] New: conj() ignored with tree loop vectorizer michelemartone at users dot sourceforge.net
                   ` (3 preceding siblings ...)
  2022-01-12 22:13 ` michelemartone at users dot sourceforge.net
@ 2022-01-13  8:05 ` rguenth at gcc dot gnu.org
  2022-01-13  9:15 ` marxin at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-01-13  8:05 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2022-01-13
           Keywords|                            |needs-bisection
                 CC|                            |marxin at gcc dot gnu.org,
                   |                            |rguenth at gcc dot gnu.org,
                   |                            |tnfchris at gcc dot gnu.org
             Blocks|                            |53947
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed on the GCC 11 branch head, I suspect it's something to do with SLP
patterns and I cannot reproduce with recent GCC 12.

Tamar, are there any fixes that need backporting in this area?

Martin, can you bisect what fixed it on trunk?


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53947
[Bug 53947] [meta-bug] vectorizer missed-optimizations

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

* [Bug tree-optimization/103995] [11/12 Regression] conj() ignored with tree loop vectorizer
  2022-01-12 17:47 [Bug tree-optimization/103995] New: conj() ignored with tree loop vectorizer michelemartone at users dot sourceforge.net
                   ` (4 preceding siblings ...)
  2022-01-13  8:05 ` rguenth at gcc dot gnu.org
@ 2022-01-13  9:15 ` marxin at gcc dot gnu.org
  2022-01-13 10:04 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-01-13  9:15 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|needs-bisection             |

--- Comment #5 from Martin Liška <marxin at gcc dot gnu.org> ---
Fixed on master with r12-2573-g3c91efec15af4f92.

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

* [Bug tree-optimization/103995] [11/12 Regression] conj() ignored with tree loop vectorizer
  2022-01-12 17:47 [Bug tree-optimization/103995] New: conj() ignored with tree loop vectorizer michelemartone at users dot sourceforge.net
                   ` (5 preceding siblings ...)
  2022-01-13  9:15 ` marxin at gcc dot gnu.org
@ 2022-01-13 10:04 ` rguenth at gcc dot gnu.org
  2022-01-13 10:54 ` cvs-commit at gcc dot gnu.org
  2022-01-13 10:54 ` rguenth at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-01-13 10:04 UTC (permalink / raw)
  To: gcc-bugs

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

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 #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
Mine then.

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

* [Bug tree-optimization/103995] [11/12 Regression] conj() ignored with tree loop vectorizer
  2022-01-12 17:47 [Bug tree-optimization/103995] New: conj() ignored with tree loop vectorizer michelemartone at users dot sourceforge.net
                   ` (6 preceding siblings ...)
  2022-01-13 10:04 ` rguenth at gcc dot gnu.org
@ 2022-01-13 10:54 ` cvs-commit at gcc dot gnu.org
  2022-01-13 10:54 ` rguenth at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-01-13 10:54 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 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:7f49f50f756c06f4093358ff77c11152777fff1c

commit r11-9458-g7f49f50f756c06f4093358ff77c11152777fff1c
Author: Richard Biener <rguenther@suse.de>
Date:   Wed Jul 28 15:12:00 2021 +0200

    tree-optimization/101615 - SLP permute opt with CTOR roots

    CTOR roots are not explicitely represented so we have to make sure
    to materialize permutes on SLP graph entries to them.

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

            PR tree-optimization/101615
            PR tree-optimization/103995
            * tree-vect-slp.c (vect_optimize_slp): Materialize permutes
            at CTOR SLP graph entries.

            * gcc.dg/vect/bb-slp-pr101615-2.c: New testcase.

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

* [Bug tree-optimization/103995] [11/12 Regression] conj() ignored with tree loop vectorizer
  2022-01-12 17:47 [Bug tree-optimization/103995] New: conj() ignored with tree loop vectorizer michelemartone at users dot sourceforge.net
                   ` (7 preceding siblings ...)
  2022-01-13 10:54 ` cvs-commit at gcc dot gnu.org
@ 2022-01-13 10:54 ` rguenth at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-01-13 10:54 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED
      Known to work|                            |12.0

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
In my testing this fixed it on the branch.

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

end of thread, other threads:[~2022-01-13 10:54 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-12 17:47 [Bug tree-optimization/103995] New: conj() ignored with tree loop vectorizer michelemartone at users dot sourceforge.net
2022-01-12 17:59 ` [Bug tree-optimization/103995] " michelemartone at users dot sourceforge.net
2022-01-12 19:17 ` [Bug tree-optimization/103995] [11/12 Regression] " pinskia at gcc dot gnu.org
2022-01-12 22:12 ` michelemartone at users dot sourceforge.net
2022-01-12 22:13 ` michelemartone at users dot sourceforge.net
2022-01-13  8:05 ` rguenth at gcc dot gnu.org
2022-01-13  9:15 ` marxin at gcc dot gnu.org
2022-01-13 10:04 ` rguenth at gcc dot gnu.org
2022-01-13 10:54 ` cvs-commit at gcc dot gnu.org
2022-01-13 10:54 ` 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).