From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8FD6C3858C52; Fri, 12 Aug 2022 14:01:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8FD6C3858C52 From: "roger at nextmovesoftware dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/106594] [13 Regression] sign-extensions no longer merged into addressing mode Date: Fri, 12 Aug 2022 14:01:46 +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: 13.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: roger at nextmovesoftware dot com 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: 13.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cf_reconfirmed_on bug_status cc everconfirmed 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: Fri, 12 Aug 2022 14:01:46 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106594 Roger Sayle changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2022-08-12 Status|UNCONFIRMED |NEW CC| |roger at nextmovesoftware = dot com Ever confirmed|0 |1 --- Comment #3 from Roger Sayle --- Ah interesting. Because index is a char, the tree-level optimizers realize that the shift by 4 can be an 8-bit shift instead of an int-sized shift.=20 What's interesting is that because of (x & 3) << 4, is used, the optimizers realize that because index can never be negative, that in the array memory reference expression constellation_64qam[index], when the 8-bit index is be= ing sign extended, it is effectively being zero-extended. I think that the aarch64 backend needs to be taught that in this case (beca= use of the AND), the zero extension is the same as (can be implemented using) a sign-extension, i.e. restoring the original code generation. Practically, = the sxtw;ldr[..lsl 2] above can legitimately be optimized to ldr[..sxtw 2] (or ldr[..uxtw 2] like LLVM) in this case [cases like this]. (sign_extend:DI (and:SI x (const_int 3))) and (zero_extend:DI (and:SI x (const_int 3))) should (ideally) produce the exact same code [the more efficient if two implementations are possible].=