From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6AA7E3874C3C; Thu, 11 Mar 2021 09:07:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6AA7E3874C3C From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/96135] [9/10/11 regression] bswap not detected by bswap pass, unexpected results between optimization levels Date: Thu, 11 Mar 2021 09:07:45 +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: 11.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 9.4 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: attachments.created 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Mar 2021 09:07:45 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96135 --- Comment #2 from Richard Biener --- Created attachment 50361 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D50361&action=3Dedit WIP On current trunk at -O3 f() again works via store-merging / vectorizing: - _21 =3D {_3, _4, _5, _6, _7, _8, _9, _10}; + bswapsrc_22 =3D (long unsigned int) i_2(D); + bswapdst_19 =3D __builtin_bswap64 (bswapsrc_22); + _21 =3D VIEW_CONVERT_EXPR(bswapdst_19); but g() does not, because init_symbolic_number doesn't like non-integral ty= pes. Fixing that generates _Z1gd: .LFB2: .cfi_startproc movq %xmm0, %rax bswap %rax ret but with -m32 it has the issue that we bswap only the lower part since vectorizing produced two vector CTORs. So we'd need to use a BIT_FIELD_REF to extract the integer representation. WIP patch attached.=