From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 51DA3385841A; Sat, 25 Feb 2023 19:50:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 51DA3385841A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677354611; bh=zFjEEYfF9UYQzPm2+ETOVSK4G1d5JvIF3OwTJEXvZYY=; h=From:To:Subject:Date:From; b=S9f41HcxcJEWtPdbEn3sfFyV3RSgmp237Zs+un7uKT2/qZxrmHJ3Ja3EfPMkhunZV UEftDuHjNL9wdFgRcJD7SZPaR/nNm7SV5Nx5r47lAJEbUSSK6K88x7LJWRGPRjGSl5 tE2CvAzRgrdwEUN3ZHVIGV6rqZ+hna5CUYll7wOk= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/108933] New: [10/11/12/13 Regression] Missing bswap detection Date: Sat, 25 Feb 2023 19:50:10 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org 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 keywords bug_severity priority component assigned_to reporter cc dependson blocked 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=3D108933 Bug ID: 108933 Summary: [10/11/12/13 Regression] Missing bswap detection Product: gcc Version: 13.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org CC: ktkachov at gcc dot gnu.org, unassigned at gcc dot gnu.= org Depends on: 108874 Blocks: 94094 Target Milestone: --- Target: arm This is the arm version of this bug. +++ This bug was initially created as a clone of Bug #108874 +++ If we look at the arm testcases in gcc.target/arm/rev16.c typedef unsigned int __u32; __u32 __rev16_32_alt (__u32 x) { return (((__u32)(x) & (__u32)0xff00ff00UL) >> 8) | (((__u32)(x) & (__u32)0x00ff00ffUL) << 8); } __u32 __rev16_32 (__u32 x) { return (((__u32)(x) & (__u32)0x00ff00ffUL) << 8) | (((__u32)(x) & (__u32)0xff00ff00UL) >> 8); } we should be able to generate rev16 instructions for aarch64 (and arm) i.e. recognise a __builtin_bswap16 essentially. GCC fails to do so and generates: __rev16_32_alt: lsr w1, w0, 8 lsl w0, w0, 8 and w1, w1, 16711935 and w0, w0, -16711936 orr w0, w1, w0 ret __rev16_32: lsl w1, w0, 8 lsr w0, w0, 8 and w1, w1, -16711936 and w0, w0, 16711935 orr w0, w1, w0 ret whereas clang manages to recognise it all into: __rev16_32_alt: // @__rev16_32_alt rev16 w0, w0 ret __rev16_32: // @__rev16_32 rev16 w0, w0 ret does the bswap pass need some tweaking perhaps? Looks like this worked fine with GCC 5 but broke in the GCC 6 timeframe so marking as a regression Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94094 [Bug 94094] [meta-bug] store-merging and/or bswap load/store-merging missed optimizations https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108874 [Bug 108874] [10/11/12/13 Regression] Missing bswap detection=