From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id ADE633858C74; Mon, 23 Oct 2023 19:40:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ADE633858C74 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1698090014; bh=zQBamyG/5bNCkRIu4+ejQds0DoybmM1q88W/3ngtMjw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=A7ZgD3HrbxrB0xG5/kQ6GqqIqPf2CUSXAN2Liw9prMa5p/pE0rSJGWp+rXtmlDXx0 bw7PEPEU1xut5tZhJhgiLMMk5UXv04NwwEq9EoBLUZiiiW6GC+Bh4H9G/2Z/ORHexM cqMRaZeCuMEPoEI3VQ1kH+DtDUpEBI7zQsR8VD54= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/111913] [14 Regression] ICE with __builtin_popcount(X) + __builtin_popcount(Y) simplification Date: Mon, 23 Oct 2023 19:40:14 +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: 14.0 X-Bugzilla-Keywords: ice-on-valid-code, needs-bisection X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: pinskia at gcc dot gnu.org X-Bugzilla-Target-Milestone: 14.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: assigned_to bug_status 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D111913 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|unassigned at gcc dot gnu.org |pinskia at gcc dot = gnu.org Status|NEW |ASSIGNED --- Comment #3 from Andrew Pinski --- I have a fix. Basically the pattern: ``` /* popcount(X&Y) + popcount(X|Y) is popcount(x) + popcount(Y). */ (simplify (plus:c (POPCOUNT:s (bit_and:s @0 @1)) (POPCOUNT:s (bit_ior:cs @0 @1))) (plus (POPCOUNT @0) (POPCOUNT @1))) ``` Needs a small help with the type that popcount returns. So: ``` /* popcount(X&Y) + popcount(X|Y) is popcount(x) + popcount(Y). */ (simplify (plus:c (POPCOUNT:s (bit_and:s @0 @1)) (POPCOUNT:s (bit_ior:cs @0 @1))) (plus (POPCOUNT:type @0) (POPCOUNT:type @1))) ```=