From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 499A13858D39; Mon, 6 Mar 2023 09:55:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 499A13858D39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678096549; bh=mg+R7P4i0zGp/QVFNBz5O2iwpqWz3opMl2270IzIRXQ=; h=From:To:Subject:Date:From; b=OTlHp3Qqu3z6c8IZ4RgwFwXHSPMaVEzFCKZ6sgySI5UrVfYeSEFJZz+lT8XOIHCrx cysbTvBi8W3wdS33rNSOrNXybS5Pbl3yxeWKl5GZGNsnhdGPy57ep9Ne8EJ3D2gxXy FGe8FRcIsehdrnlp0o+c+7UstwfX8aum7a1+3ffc= From: "crazylht at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/109038] New: Miss optimization to simplify bit_and + rotate to shift Date: Mon, 06 Mar 2023 09:55:49 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: crazylht at gmail dot com X-Bugzilla-Status: UNCONFIRMED 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone cf_gcctarget 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=3D109038 Bug ID: 109038 Summary: Miss optimization to simplify bit_and + rotate to shift Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: crazylht at gmail dot com Target Milestone: --- Target: x86_64-*-* i?86-*-* unsigned foo (unsigned int a) { unsigned int b =3D a & 0x00FFFFFF; unsigned int c =3D ((b & 0x000000FF) << 8 | (b & 0x0000FF00) << 8 | (b & 0x00FF0000) << 8 | (b & 0xFF000000) >> 24); return c; } gcc generates foo: mov eax, edi and eax, 16777215 rol eax, 8 ret But it can be optimized as below foo: # @foo mov eax, edi shl eax, 8 ret=