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

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).