From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 315D139730ED; Tue, 2 Feb 2021 13:20:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 315D139730ED From: "kristian.klausen at scoutdi dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/98932] New: Wrong output with -O3 on aarch64 Date: Tue, 02 Feb 2021 13:20:35 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 8.4.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: kristian.klausen at scoutdi dot com 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 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: Tue, 02 Feb 2021 13:20:36 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D98932 Bug ID: 98932 Summary: Wrong output with -O3 on aarch64 Product: gcc Version: 8.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: kristian.klausen at scoutdi dot com Target Milestone: --- Hi,=20 I have been struggling with a vectorization issue, and have managed to re-create to a minimal example as attached.=20 When compiled with `-O2` the correct output is produced, however when compi= led with `-O3` the output is bogus when compiled with gcc-8 and gcc-9. Gcc-7 gi= ves the correct output.=20 Tested with the following versions under qemu for aarch64:=20 ``` g++-7 --version g++-7 (Ubuntu/Linaro 7.5.0-6ubuntu2) 7.5.0 g++-8 --version g++-8 (Ubuntu/Linaro 8.4.0-3ubuntu2) 8.4.0 g++-9 --version g++-9 (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0 ``` Output:=20 ``` :~# g++-9 -O3 a.cpp && ./a.out Length is: 26348240 :~# g++-8 -O3 a.cpp && ./a.out Length is: 26348240 :~# g++-7 -O3 a.cpp && ./a.out Length is: 294 ``` Also gave it a go with the suggested flags before filing the report:=20 ``` g++-8 -O3 -Wall -Wextra -fno-strict-aliasing -fwrapv a.cpp && ./a.out Length is: 26348240 ``` The code gives the correct output with gcc-10:=20 ``` g++-10 -O3 a.cpp && ./a.out Length is: 294 g++-10 --version g++-10 (Ubuntu 10.2.0-5ubuntu1~20.04) 10.2.0 ``` Let me know if I can provide more information.=20 Best, Kristian=