From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 68F693858D39; Wed, 22 Sep 2021 10:56:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 68F693858D39 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/102446] [9/10/11/12 Regression] wrong code at -O3 on x86_64-linux-gnu Date: Wed, 22 Sep 2021 10:56:26 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 9.5 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: 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: Wed, 22 Sep 2021 10:56:26 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102446 --- Comment #3 from Richard Biener --- void m() { int aa =3D 0, i =3D 0; for (; i < 3; i++) if (k < 0) aa |=3D *j; Dump of assembler code for function m: 0x0000000000400540 <+0>: mov 0x200b16(%rip),%edi # 0x60105c 0x0000000000400546 <+6>: mov 0x200b13(%rip),%rax # 0x601060 0x000000000040054d <+13>: sar $0x1f,%edi =3D> 0x0000000000400550 <+16>: and (%rax),%edi 0x0000000000400552 <+18>: cmpw $0x0,0x200af6(%rip) # 0x601050 so we're loading *j before checking k < 0. On GIMPLE that's OK: [local count: 268435456]: k.5_1 =3D k; j.6_2 =3D j; if (k.5_1 < 0) goto ; [41.00%] else goto ; [59.00%] [local count: 110058537]: j.6__lsm0.31_28 =3D *j.6_2; [local count: 268435456]: # aa_9 =3D PHI but RTL if-conversion makes the load unconditional. (insn 13 12 35 3 (set (reg/v:SI 89 [ j.6__lsm0.31 ]) (mem:SI (reg/f:DI 83 [ j.6_2 ]) [1 *j.6_2+0 S4 A32])) 77 {*movsi_internal} (expr_list:REG_DEAD (reg/f:DI 83 [ j.6_2 ]) (nil))) I don't see any flags marking it as not trapping?=