From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0A3913858C83; Tue, 15 Feb 2022 18:01:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0A3913858C83 From: "vsevolod.livinskij at frtk dot ru" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/104551] New: Wrong code with -O3 for skylake-avx512, icelake-server, and sapphirerapids Date: Tue, 15 Feb 2022 18:01:23 +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: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vsevolod.livinskij at frtk dot ru 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, 15 Feb 2022 18:01:24 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104551 Bug ID: 104551 Summary: Wrong code with -O3 for skylake-avx512, icelake-server, and sapphirerapids Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: vsevolod.livinskij at frtk dot ru Target Milestone: --- Reproducer (I was not able to merge it into a single file): // func.cpp extern unsigned var_11, var_178; extern unsigned char arr_492[]; void test() { for (bool a =3D 0; a < (bool)var_11; a =3D 2) for (unsigned b =3D 0; b < var_11; b +=3D 1) var_178 =3D arr_492[b] ? arr_492[b] : (char) b; } // driver.cpp=20 unsigned int var_11 =3D 16U; unsigned int var_178 =3D 0; unsigned char arr_492 [16]; void test(); int main() { for (int i =3D 0; i < 16; ++i) arr_492 [i] =3D (unsigned char)128; test(); __builtin_printf("%u\n", var_178); if (var_178 !=3D 128) __builtin_abort(); return 0; } Error: >$ g++ -O0 func.cpp driver.cpp -march=3Dskylake-avx512 && sde -skx -- ./a.o= ut=20 128 >$ g++ -O3 func.cpp driver.cpp -march=3Dskylake-avx512 && sde -skx -- ./a.o= ut=20 4294967168 Aborted (core dumped) g++ (git://gcc.gnu.org/git/gcc.git:master 58aeb75d4097010ad9bb72b964265b18ab284f93) 12.0.1 20220213 (experimental)=