From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 743C5385843F; Wed, 16 Feb 2022 14:05:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 743C5385843F From: "amacleod at redhat dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/104526] [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs. 11.2.0) Date: Wed, 16 Feb 2022 14:05:23 +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: amacleod at redhat dot com X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: FIXED X-Bugzilla-Priority: P1 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: Wed, 16 Feb 2022 14:05:23 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104526 --- Comment #7 from Andrew Macleod --- On 2/16/22 07:39, jakub at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104526 > > --- Comment #6 from Jakub Jelinek --- > + tree type =3D TREE_TYPE (TREE_OPERAND (cond, 0)); > + if (type !=3D TREE_TYPE (TREE_OPERAND (cond, 1))) > + return false; > looks unnecessarily restrictive. > What tree-cfg.cc verification guarantees (and no need to check it in the > ranger) > is what verify_gimple_comparison verifies, i.e. that > /* For comparisons we do not have the operations type as the > effective type the comparison is carried out in. Instead > we require that either the first operand is trivially > convertible into the second, or the other way around. */ > if (!useless_type_conversion_p (op0_type, op1_type) > && !useless_type_conversion_p (op1_type, op0_type)) > I think the ranger has to be prepared for non-pointer-equal type mismatch= es as > long as they are useless_type_conversion_p compatible, that can happen an= ywhere > in the IL, including even cases like different but useless_type_conversio= n_p > compatible types of binary operators like +, -, * etc. > So I'd just remove the > if (type !=3D TREE_TYPE (TREE_OPERAND (cond, 1))) > return false; > lines. The rest of ranger isn't this restrictive.. it is satisfied by=20 range_compatable_p() which boils down to "same precision, same sign". I added it here so to be super paranoid so I didn't get caught by=20 something unexpected later in the routine and cause an ICE in intersect=20 in the middle of building the kernel or something.=C2=A0 In hindsight, I=20 should have used range_compatible_p... Are you OK with the following change?=C2=A0 I'll bootstrap and regression t= est... Andrew=