From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 24AAC3952009; Fri, 12 Jun 2020 04:25:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 24AAC3952009 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1591935936; bh=N39yrx3aKPFx1uX90kA6YsVoga7OKf+qdpQbH8Xc4mg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Mpj7qg7ldncGzvKyrX69idSypWOFdzgVeRvJBSr3d5k+tWQp5SsGgEXH+5dy+m5me fXaSWKAyHbPqsn1uSoyKdZrBwybFiWG0k9yQpLnFLZ971q14EdTH3oeVe6pHjBZuK6 oesi2es501CbzOfi3BwLTLJ12ujXTWyEc7/omqDI= From: "wilson at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/95632] Redundant zero extension Date: Fri, 12 Jun 2020 04:25:35 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 10.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: wilson 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: cf_reconfirmed_on bug_status 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 Jun 2020 04:25:36 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95632 Jim Wilson changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2020-06-12 Status|UNCONFIRMED |NEW Ever confirmed|0 |1 --- Comment #1 from Jim Wilson --- We sign extend HImode constants as that is the natural thing to do to make arithmetic work. This does mean that unsigned short logical operations nee= d a zero extend after the operation which might otherwise be unnecessary. This can't be handled at rtl generation time as we don't know if the constant wi= ll be used for arithmetic or logicals or signed or unsigned. But maybe an optimization pass could go over the code and convert HImode constants to si= gned or unsigned as appropriate to reduce the number of sign/zero extend operati= ons. We have the ree pass that we might be able to extend to handle this. Handling this in combine requires a 4->3 splitter which is something combine doesn't do. We could work around that by not splitting constants before combine, but that would be a major change and probably not beneficial, as we wouldn't be able to easily optimize the high part of the constants anymore. Another approach here might be to split the xor along with the constant. I= f we generated something like srli a0,a0,1 xori a0,a0,1 li a5,-24576 xor a0,a0,a5 then we can optimize away the following zero extend with a 3->2 splitter wh= ich combine already supports via find_split_point. We can still optimize the h= igh part of the constant. Since the immediates are sign extended, if the low pa= rt of the immediate has the sign bit set, we would have to invert the high par= t of the immediate to get the right result. At least I think that works, I have= n't double checked it yet. This only works for or if the low part doesn't have= the sign bit set. And this only works for and if the low part does have the si= gn bit set.=