From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 076933857C56; Thu, 24 Jun 2021 20:50:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 076933857C56 From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/101200] Unneeded AND after shift Date: Thu, 24 Jun 2021 20:50:46 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Version: 11.1.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: pinskia 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: bug_status everconfirmed cf_reconfirmed_on cf_gcctarget 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, 24 Jun 2021 20:50:47 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101200 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Ever confirmed|0 |1 Last reconfirmed| |2021-06-24 Target| |x86_64-linux-gnu --- Comment #3 from Andrew Pinski --- For aarch64 we get: adrp x1, .LANCHOR0 add x0, x1, :lo12:.LANCHOR0 add x0, x0, 8 ldrb w1, [x1, #:lo12:.LANCHOR0] and x2, x1, 15 ubfx x1, x1, 4, 4 ldr w2, [x0, x2, lsl 2] str w2, [x0, x1, lsl 2] ret Note the shift and and is combined into one instruction (ubfx) but really o= nly a shift instruction is needed. Here we have: Trying 21 -> 22: 21: r112:SI=3Dr92:SI 0>>0x4 REG_DEAD r92:SI 22: r113:DI=3Dsign_extend(r112:SI) REG_DEAD r112:SI Successfully matched this instruction: (set (reg:DI 113) (zero_extract:DI (subreg:DI (reg:SI 92 [ d.0_1 ]) 0) (const_int 4 [0x4]) (const_int 4 [0x4]))) The multiple modes issue is part of the problem. If I was redesigning the backends, I would only allow DI mode (and SI mode for i386) and always have= the zero extends on loads.=