From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 69040385840C; Wed, 12 Jan 2022 17:47:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 69040385840C From: "michelemartone at users dot sourceforge.net" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/103995] New: conj() ignored with tree loop vectorizer Date: Wed, 12 Jan 2022 17:47:38 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 11.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: michelemartone at users dot sourceforge.net X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Jan 2022 17:47:38 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103995 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=3D52173&action=3Dedit 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.=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20 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 bu= ggy && ./buggy Using ASAN: gcc -c -O3 -fsanitize=3Daddress -fno-omit-frame-pointer buggy.c && = gcc -c -O3 -fsanitize=3Daddress -fno-omit-frame-pointer main.c && gcc buggy.o -las= an main.o -o buggy && ./buggy=20=20=20 it does not reproduce. Reproducer flags with lower optimization are: gcc -c -O1 -ftree-loop-vectorize -ftree-slp-vectorize buggy.c && gc= c -c -O0 main.c && gcc -O0 buggy.o main.o -o buggy && ./buggy This can be minimized further by deactivating the individual -O1 flags list= ed on https://gcc.gnu.org/onlinedocs/gcc-11.2.0/gcc/Optimize-Options.html#index-f= tree-dse using (-fno-...), exception made for two flags: -ftree-ch and -ftree-forwpr= op. Using:=20=20 -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.=