From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B54063985417; Sat, 23 May 2020 21:56:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B54063985417 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1590270977; bh=alpDrs2LSUJ1Ad6hboGjCKabVPODez+Exxzc8a1HAm4=; h=From:To:Subject:Date:From; b=chfkmb3A+bwykzemTuS9YpjBazvzVa5gxHFzyIEWlyS/L183wVzXX2H5WJoeMe17g AjFhjE9OdWD41VDfDdwlR/8B2P6XT4kFtMhTWgwXr9Ybps3aUpFa2vZWUjTqGT6dIB ihZ7YzPFPbpMCZghoUQEEoITwynKDVt2WH6JgSJI= From: "vsevolod.livinskij at frtk dot ru" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/95295] New: g++ produces incorrect code with -O3 for loops Date: Sat, 23 May 2020 21:56:17 +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: Sat, 23 May 2020 21:56:17 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95295 Bug ID: 95295 Summary: g++ produces incorrect code with -O3 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++ func.cpp driver.cpp -O0 && ./a.out=20 1 >$ g++ func.cpp driver.cpp -O3 && ./a.out=20 0 Reproducer: func.cpp extern int var_4, a; extern unsigned var_9; extern short arr_272[]; void test() { for (int b =3D 0; b < 9; b++) for (int c =3D 0; c < 9; c +=3D 4) { arr_272[c] =3D var_9 ? var_4 : 0; a =3D 0; } } driver.cpp #include unsigned long long a; int var_4 =3D 1; short var_9 =3D 8; short arr_272[20]; void test(); int main() { test(); printf("%d\n", arr_272[4]); } GCC version: 11.0.0 (bcb63eb2cbd3caf212b9cf42d8c218c09dc6ff8b)=