From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E35E73851AB8; Fri, 18 Aug 2023 06:36:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E35E73851AB8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1692340604; bh=jqt2vUb8VEaGw/aoldSMEZS7rSkO13l96RkXU0YkYoQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=neGVOW31E2XgPmUqmGqvhUNO6UtufA3DN36VIkiKRUM3lToUA2MtuWBTzCTxnicch oXXMtTEKDqBdHOSDaQnGGYyhiKXGoJ0xobuwRmtKNKaolr6p16PKWKQA3/+2hmLFZK sshA6E0kQvEnNCCU0YqJKxEdEgi7rMiZ8ePG49hM= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/99987] [12/13/14 Regression] missed optimization for dead code elimination at -O3 (vs. -O2) Date: Fri, 18 Aug 2023 06:36:44 +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: 11.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia 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: 12.4 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cf_known_to_fail 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99987 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Known to fail| |7.5.0 --- Comment #6 from Andrew Pinski --- So this is bascially the missed optimization: ``` void foo(void); int main() { unsigned h =3D 123+5; for(unsigned g =3D 123; g !=3D 0; g--) { h--; if(h =3D=3D 0) foo(); } } ``` The relationship between h and g is `h =3D g + 5` so you can never get `h = =3D=3D 0` in the loop as the range of g is [123,0]. Note In the original testcase, only GCC 8-11 dom3 (on x86_64; but not on aarch64 due to IVOPTS differences) could optimize away the call to foo. Also note LLVM can optimize it away both the above testcase and the original one.=