From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id EC2053858432; Wed, 16 Feb 2022 12:39:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EC2053858432 From: "jakub at gcc dot gnu.org" 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 12:39:39 +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: jakub at gcc dot gnu.org 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 12:39:40 -0000 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 mismatches= as long as they are useless_type_conversion_p compatible, that can happen anyw= here in the IL, including even cases like different but useless_type_conversion_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.=