From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 49446384B000; Thu, 25 Apr 2024 17:47:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 49446384B000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1714067260; bh=+BwCAIJhFoHd/WM2s6o4O5hgbBE6s8kb6MDY6v8cj6Q=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ARSkAsuzQrL4se9uma3XKWQ3olujPQsPfrrLllydEYoVAKomNzbezlAQ32MWfxeet 7BRg+Im9d20mCRs0gqmlUA36xZfMkclVF79v4qNKlNSs5H3uESXZWUNeP0049LQGiF VkNqiLZHw2F4G2nQfcZT4UK6aWUWnFlD57bvLepE= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/114853] Inefficient code with a bunch of bitwise checks Date: Thu, 25 Apr 2024 17:47:38 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 13.2.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: pinskia at gcc dot gnu.org 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: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: component 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=3D114853 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Component|tree-optimization |middle-end --- Comment #4 from Andrew Pinski --- So what is happening is there is a missed Canonicalization happening here at the gimple level and only at the RTL level we decide to expand `(num & 7LL)= =3D=3D 7LL` as `((~num) & 7) =3D=3D 0` (for x86_64). For aarch64 we expand still a= s `(num &7) =3D=3D 7`. So we should pick one for the gimple level and then expand it and also actu= ally do better CSE of `~num` for the RTL level. The other thing GCC should do better at is handle: ``` bool checko(long long num) { if((num & 7LL) =3D=3D 7LL) return true; if((num & 22LL) =3D=3D 22LL) return true; return false; } ``` Into: ``` and x1, x0, 7 mov x2, 22 cmp x1, 7 and x0, x0, x2 ccmp x0, x2, 4, ne cset w0, eq ``` For aarch64. I have an idea there ...=