From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 816213858C53; Fri, 25 Aug 2023 01:37:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 816213858C53 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1692927433; bh=Lv4DlRxwESLht1Z/2GggS1VhiPZCoPGgqu0zcdmtzzA=; h=From:To:Subject:Date:From; b=oAcAcSFds2m6loATi+AQOW3erlFr4IC6WbKvZ40fzXBN1x0TV70xOyGFCYyyR0gq/ izq2p5vMoqZtr8xDe7Prx4QAZwzk3Ji4+bQdkZcHA5Q5LUzXVnqzGa03qGIhS6GVfn Xb1YPzp+5xeltxn7XMslrftd1jLdlNKJlbV8+ud8= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/111147] New: bitwise_inverted_equal_p can be used in the `(x | y) & (~x ^ y)` pattern to catch more Date: Fri, 25 Aug 2023 01:37:13 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: pinskia at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status keywords bug_severity priority component assigned_to reporter target_milestone Message-ID: 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=3D111147 Bug ID: 111147 Summary: bitwise_inverted_equal_p can be used in the `(x | y) & (~x ^ y)` pattern to catch more Product: gcc Version: 14.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P3 Component: tree-optimization Assignee: pinskia at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- Take: ``` int g(int x, int y) { return (x | y) & (~x ^ y); // x & y } int g0(int x, int y) { return (~x | y) & (x ^ y); // ~x & y } ``` g is correctly optimized to `x & y` but g0 is not optimized to `~x & y` even though it could be. If this pattern used bitwise_inverted_equal_p it could be. Note this could also be used to catch comparisons too. Filing this not to lose this idea.=