From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id E71D43858C66 for ; Mon, 13 Feb 2023 21:13:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E71D43858C66 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 129BB4B3; Mon, 13 Feb 2023 13:14:37 -0800 (PST) Received: from localhost (e121540-lin.manchester.arm.com [10.32.99.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F35563F663; Mon, 13 Feb 2023 13:13:53 -0800 (PST) From: Richard Sandiford To: Jeff Law Mail-Followup-To: Jeff Law ,gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] lra: Replace subregs in bare uses & clobbers [PR108681] References: Date: Mon, 13 Feb 2023 21:13:52 +0000 In-Reply-To: (Jeff Law's message of "Sun, 12 Feb 2023 23:58:21 -0700") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-29.1 required=5.0 tests=BAYES_00,KAM_DMARC_NONE,KAM_DMARC_STATUS,KAM_LAZY_DOMAIN_SECURITY,KAM_SHORT,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Jeff Law writes: > On 2/7/23 03:29, Richard Sandiford via Gcc-patches wrote: >> In this PR we had a write to one vector of a 4-vector tuple. >> The vector had mode V1DI, and the target doesn't provide V1DI >> moves, so this was converted into: >> >> (clobber (subreg:V1DI (reg/v:V4x1DI 92 [ b ]) 24)) >> >> followed by a DImode move. (The clobber isn't really necessary >> or helpful for a single word, but would be for wider moves.) >> >> The subreg in the clobber survived until after RA: >> >> (clobber (subreg:V1DI (reg/v:V4x1DI 34 v2 [orig:92 b ] [92]) 24)) > Post-reload all (subregs (reg)) expressions are supposed to be > simplified. At least that's my recollection. Though it looks like we > don't force the simplification until final assembly output. > > One might question under what circumstances simplifying (subreg (reg)) > can legitimately fail. My memory's hazy, but I think e500 had instances of this. e500's long gone though, so maybe it's a non-issue now. >> IMO this isn't well-formed. If a subreg of a hard register simplifies >> to a hard register, it should be replaced by the hard register. If the >> subreg doesn't simplify, then target-independent code can't be sure >> which parts of the register are affected and which aren't. A clobber >> of such a subreg isn't useful and (again IMO) should just be removed. >> Conversely, a use of such a subreg is effectively a use of the whole >> inner register. > Agreed. > > I'm not even sure that naked USE/CLOBBERS have any value post-reload > except for the use of the return register(s) and those inserted by > reorg. But changing that at this stage seems inadvisable. Yeah, not sure either about USEs. I think the CLOBBERs can still be useful as a way of avoiding partially-uninitialised registers becoming too upwards-exposed. E.g. when a 4-register hardreg is used and only one register is set, the CLOBBER prevents the other 3 registers being live on entry, or at least being kept live after some earlier unrelated use. That should give things like regrename more freedom. Thanks for the review, now pushed. Richard >> LRA has code to simplify subregs of hard registers, but it didn't >> handle bare uses and clobbers. The patch extends it to do that. >> >> One question was whether the final_p argument to alter_subregs >> should be true or false. True is IMO dangerous, since it forces >> replacements that might not be valid from a dataflow perspective, >> and uses and clobbers only exist for dataflow. As said above, >> I think the correct way of handling a failed simplification would >> be to delete clobbers and replace uses of subregs with uses of >> the inner register. But I didn't want to write untested code >> to do that. > I'd go with "false" here after reviewing the code. > > > >> >> In the PR, the clobber caused an infinite loop in DCE, because >> of a disagreement about what effect the clobber had. But for >> the reasons above, I think that was GIGO rather than a bug in >> DF or DCE. >> >> Tested on aarch64-linux-gnu & x86_64-linux-gnu. OK to install? >> >> Richard >> >> >> gcc/ >> PR rtl-optimization/108681 >> * lra-spills.cc (lra_final_code_change): Extend subreg replacement >> code to handle bare uses and clobbers. >> >> gcc/testsuite/ >> PR rtl-optimization/108681 >> * gcc.target/aarch64/pr108681.c: New test. > OK > jeff