From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 521CD3858003; Tue, 22 Feb 2022 10:39:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 521CD3858003 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/104632] Missed optimization about reading backwards Date: Tue, 22 Feb 2022 10:39:43 +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.2.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: rguenth 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: everconfirmed cf_reconfirmed_on bug_status 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: Tue, 22 Feb 2022 10:39:43 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104632 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Last reconfirmed| |2022-02-22 Status|UNCONFIRMED |NEW --- Comment #3 from Richard Biener --- The bswap pass is supposed to handle these but has bool find_bswap_or_nop_load (gimple *stmt, tree ref, struct symbolic_number *n) { ... /* Avoid returning a negative bitpos as this may wreak havoc later. = */ if (maybe_lt (bit_offset, 0)) { commenting the code produces the desired load_le32_backwards: .LFB0: .cfi_startproc movl -4(%rdi), %eax ret the code is present since the introduction of memory source to the bswap pa= ss. It needs to be investigated what exactly the "havoc" is but clearly the "ha= voc" should be mitigated closer to the offenders since the above case seems to w= ork just fine.=