From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E44B4385040D; Tue, 18 Aug 2020 22:34:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E44B4385040D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1597790076; bh=xTGGAq/FI0Nnf5oovOlM7DPY+teouQa3agGFtiGTcuc=; h=From:To:Subject:Date:From; b=D6TM1Rsmw21S7CFYuFgwFZi0068WMPF+swK7DK92k65uNVmaO9nxlDnCkEYgisDIA pXAeR1w+Bcbr8S5eH2sT/po/KwDTaKBEcQfEwo1iZQ3Q7ml4Jz9BolcpXp88fxcS32 SSnZE+Gfqt5mA/5WzuZRL+SpKXt4GdAabpnPdyGM= From: "vsevolod.livinskij at frtk dot ru" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/96693] New: GCC produces incorrect code with -O2 for loops Date: Tue, 18 Aug 2020 22:34:36 +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.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, 18 Aug 2020 22:34:37 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96693 Bug ID: 96693 Summary: GCC produces incorrect code with -O2 for loops Product: gcc Version: 11.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: --- Error: >$ g++ -O2 driver.cpp func.cpp && ./a.out 0 >$ g++ -O0 driver.cpp func.cpp && ./a.out 42 Reproducer: //func.cpp extern char var_20; extern short var_22; void test(unsigned a, bool b, long long p12[23]) { for (int c =3D 0; c < 2;) { if (b) { for (int d =3D 0; d < 4082; d +=3D 2) for (int e =3D 0; e < a; e =3D 2) var_20 =3D 0; var_22 =3D 0; } c =3D p12[c]; } } //driver.cpp=20 #include unsigned int var_4 =3D 140810747U; bool var_7 =3D (bool)0; unsigned char var_20 =3D (unsigned char)82; unsigned short var_22 =3D 42; long long int arr_9 [23] ; void test(unsigned int var_4, bool var_7, long long int arr_9 [23]); int main() { for (size_t i_0 =3D 0; i_0 < 23; ++i_0)=20 arr_9 [i_0] =3D -722784397873599555LL; test(var_4, var_7, arr_9); printf("%d\n", var_22); } GCC version: 11.0.0 20200816 (23747614cc8fc137c1f2ca64c8e224125a72fae5) + fix proposed in bug 95396=