From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 516BB3858C52; Mon, 6 Mar 2023 09:52:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 516BB3858C52 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678096323; bh=y/CD8DmAE+d56N2BMBGgPfmZ6C/wwyVkQ8RmJVEW1xo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=IMRZQwHwVnCFjDK967ryNPUj2CUK7i9662nlnUzi5Z+QzvxQCf0mVoqPncBip6Vpl a0T4nFwnmYadlfOKYvFi3PkgME6GAIWj4TqYqsStJAbTPMU1b6dNZcENVuAHRnGjRe ud2KTYi7yeA+A2oj8SwQX0clhVBesyKSl4y6Nu5g= From: "crazylht at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/108938] Missing bswap detection Date: Mon, 06 Mar 2023 09:52:02 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target 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: 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=3D108938 --- Comment #5 from Hongtao.liu --- (In reply to Jakub Jelinek from comment #4) > And perhaps next to rotate it could try some left or right (logical) shift > too. Yes, we have bit mask in bswap detection, left or right (logical) shift can= be reprensented as special bit mask + rotate. I'm cooking a patch, for shift cases, it looks like gimple doesn't simplify= bit mask + rotate to shift. .i.e. 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=