From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id EFBD13858405; Tue, 23 Nov 2021 13:09:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EFBD13858405 From: "aldyh at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/103359] [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0) Date: Tue, 23 Nov 2021 13:09:58 +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: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: aldyh 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.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc 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: Tue, 23 Nov 2021 13:09:59 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103359 Aldy Hernandez changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |amacleod at redhat dot com --- Comment #7 from Aldy Hernandez --- (In reply to Richard Biener from comment #4) > So the important part is to eliminate the store to 'c' which GCC11 manages > to do > from EVRP while trunk fails at this task. The IL into EVRP is absoultely > identical: >=20 > : > goto ; [INV] >=20 > : > # h_10 =3D PHI <4(2), h_10(3), h_10(4), 1(7)> > d.2_8 =3D d; > if (d.2_8 !=3D 0) > goto ; [INV] >=20 > : > if (h_10 !=3D 0) > goto ; [INV] >=20 > : > e.0_1 =3D e; > if (e.0_1 !=3D 0) > goto ; [INV] >=20 > : > a.1_2 =3D a; > _3 =3D (short int) a.1_2; > _14 =3D a.1_2 & 1; > _4 =3D (short int) _14; > _5 =3D _4 | h_10; > _6 =3D (int) _5; > f.4_21 =3D (unsigned short) _5; > _23 =3D f.4_21 * 3; > _24 =3D (short int) _23; > if (_5 =3D=3D 0) > goto ; [INV] > else > goto ; [INV] >=20 > : > c =3D 0; In GCC11 we had this right before evrp: _5 =3D _4 | h_10; _6 =3D (int) _5; f.4_21 =3D (unsigned short) _5; _23 =3D f.4_21 * 3; _24 =3D (short int) _23; if (_5 =3D=3D 0) goto ; [INV] else goto ; [INV] which evrp could fold: Visiting conditional with predicate: if (_5 =3D=3D 0) With known ranges _5: short int ~[0, 0] Predicate evaluates to: 0 However, in trunk the IL is different: _5 =3D _4 | h_10; _6 =3D (int) _5; f.4_21 =3D (unsigned short) _5; _23 =3D f.4_21 * 3; _24 =3D (short int) _23; if (_24 =3D=3D 0) goto ; [INV] else goto ; [INV] Where did the cast come from in trunk? Cause without the case, we should be able to fold it. For that matter, in trunk we have: Folding statement: if (_24 =3D=3D 0) Visiting conditional with predicate: if (_24 =3D=3D 0) With known ranges _24: short int VARYING Predicate evaluates to: DON'T KNOW gimple_simplified to if (_5 =3D=3D 0) Folded into: if (_5 =3D=3D 0) So gimple fold does get rid of the cast for us, and at that point ranger can figure out the conditional: [ranger dump] if (_5 =3D=3D 0) goto ; [INV] else goto ; [INV] ... ... _5 : short int [-INF, -1][1, +INF] Presumably we're asking ranger before calling gimple fold, but the question= is, what was going on in GCC11 that the _24 =3D> _5 substitution was done before arriving in evrp.=