From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9A2F3386077E; Wed, 26 Oct 2022 00:40:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9A2F3386077E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666744808; bh=b9UkCiVXw6X4iDfxKMgubpVKrC3+I6eDgFgEijckpy4=; h=From:To:Subject:Date:From; b=hWGfJVoXhid8eoXoKFlpTHonFR/njxPOK94oVxnx3EAaIRe8eXZGC3u/4HYIfumHU Mr/S88hBRg1zlXiznOSHRyPO1ualwX2E7f/7AKPO/MKK/ZOVv47+/cdn1P2pP+SYWO PHTccR0V8WFcqdOH/jakJYTYrZtor/muzoJy7OsM= From: "vsevolod.livinskiy at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/107404] New: [12/13 Regression] Wrong code with -O3 Date: Wed, 26 Oct 2022 00:40:07 +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: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vsevolod.livinskiy at gmail 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107404 Bug ID: 107404 Summary: [12/13 Regression] Wrong code with -O3 Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: vsevolod.livinskiy at gmail dot com Target Milestone: --- Link to the Compiler Explorer: https://godbolt.org/z/jP6chErEY The reproducer is a bit too big, but it's the best I was able to achieve wi= th Creduce, Cvise, and manual reduction. UBSan and ASan say that it is complia= nt with the standard. Reproducer: #include unsigned long long a; void b(unsigned long long *f, int p2) { *f ^=3D p2; } long c; char e, i; short g, m; long long ab[1][25][21][22]; unsigned long long aa[1][21][22]; unsigned long long ae[1][25][21][21]; long long ac[129360]; char ad[25][1][21]; char ah[1][25][1][21]; short af[100]; long max(long f, unsigned long p2) { return f < p2 ? p2 : f; } const int &max2(const int &f, const int &p2) { return f < p2 ? p2 : f; } void foo(unsigned f, unsigned p2, char l, char p4, long long n[][25][21][22= ], unsigned long long p6[][21][22], unsigned long long u[][25][21][21]= ) { long an; for (int j =3D 0; j < 4; j =3D p2) for (short k =3D 0; k < 7; k +=3D 2) for (short o =3D 0; o < (short)p2 + 21742; o =3D l) { for (signed char p =3D 2; p < 9; p +=3D p4) if (p6[j][o][p]) for (long q(3); 4 ? n[0][k][o][0] : 0; q +=3D p6[0][o][0] ? p6[j][0][p] : 0) ac[j + q] =3D 5066799590; for (long r(p4 - 16); r < 21; r +=3D 4) { ad[k][o][r] =3D max(u[j][k][o][r], f + u[j][k][o][r]); long d =3D u[j][k][o][r]; an =3D d < p2 ? p2 : d; e =3D ah[j][k][o][r] =3D an; af[o * r] =3D i; } for (short s(c); s < (short)p2; s =3D 2) for (short am(m); am; am =3D max2(3, p2)) for (long y =3D 0; y; y =3D 3) for (short t(0); t < max2(g, 0);) ; } } int main() { foo(7, 1558227751, 104, 16, ab, aa, ae); for (size_t v =3D 0; v < 5; ++v) for (size_t w =3D 0; w < 1; ++w) for (size_t x =3D 0; x < 21; ++x) b(&a, ad[v][w][x]); printf("%llu\n", a); } Error: >$ g++ -O3 small.cpp && ./a.out=20 28 >$ g++ -O0 small.cpp && ./a.out=20 0 gcc version 13.0.0 20221025 (321f89e58510dd5df1b3dbe323344b987a7b11c6)=