From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 227753857C5D; Fri, 1 Oct 2021 21:02:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 227753857C5D From: "amacleod at redhat dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/102540] [12 Regression] Dead Code Elimination Regression at -O3 since r12-476-gd846f225c25c5885 Date: Fri, 01 Oct 2021 21:02:17 +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: X-Bugzilla-Severity: normal X-Bugzilla-Who: amacleod at redhat dot com 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: 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: Fri, 01 Oct 2021 21:02:18 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102540 --- Comment #4 from Andrew Macleod --- (In reply to Richard Biener from comment #2) > FRE1 has the following difference, simplifying the (unsigned int) truncat= ion. >=20 > : > a.0_1 =3D a; > _2 =3D (unsigned int) a.0_1; > b =3D _2; > - c_10 =3D (long int) _2; > + _6 =3D a.0_1 & 4294967295; > + c_10 =3D _6; > if (c_10 !=3D 0) > goto ; [INV] > else >=20 Why does FRE make this transformation/simplification? It removes a relationship between c_10 and _2. The reason ranger no longer can fold _2 = =3D=3D 0 is because the sequence is now: a.0_1 =3D a; _2 =3D (unsigned int) a.0_1; b =3D _2; _6 =3D a.0_1 & 4294967295; c_10 =3D _6; if (c_10 !=3D 0) goto ; [INV] We do not find _2 is non-zero on the outgoing edge because _2 is not relate= d to the calculation in the condition. (ie c_10 no longer has a dependency on _= 2) We do recalculate _2 based on the outgoing range of a.0_1, but with it bein= g a 64 bit value and _2 being 32 bits, we only know the outgoing range of a.0_1= is non-zero.. we dont track any of the upper bits...=20 2->3 (T) a.0_1 : long int [-INF, -1][1, +INF] And when we recalculate _2 using that value, we still get varying because 0xFFFF0000 in not zero, but can still produce a zero in _2. The problem is that the condition c_10 !=3D 0 no longer related to the valu= e of _2 in the IL... so ranger never sees it. and we cant represent the 2^16 subranges that end in [1,0xFFFF]. Before that transformation,=20 _2 =3D (unsigned int) a.0_1; b =3D _2; c_10 =3D (long int) _2; The relationship is obvious, and ranger would relate the c_10 !=3D 0 to _2 = no problem.=