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.