From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by sourceware.org (Postfix) with ESMTPS id BEB423858D33 for ; Mon, 13 Feb 2023 06:58:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BEB423858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-x102d.google.com with SMTP id on9-20020a17090b1d0900b002300a96b358so11233947pjb.1 for ; Sun, 12 Feb 2023 22:58:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=i0nl/jN0f1cPv7NVqyCz/7CtUhBNEvsRU10K+y8txro=; b=j4Vne2N1KSJRP0evjc7/1U58GYtzVxvl2GgN6ajcyCwE/CkJotStPnv7utusYp6jAY QKB0Mby3K9L4m7lbJT5busTguJZP+l6YF3ch87jJuQ31ZC1YbMxjT+Yxxbf1scu35O40 epgcQLXfqm+WOUXuZHASqHQS9UHhoW1MYzd8dibjNs20d0CDGYjurpeCFGfQy0B8chOe lesHz2pOCt9CsR7eIHSiLwHFLW5cQMhfD0YolqBLpu+76pezuZIBbNXqxIy/i4gQwYlU xMyflctCWmqRT3HsfAXbz+8FF0lqDYVetCB4gVAWuJ2RL3IOciKZqAekFThedxYQlXP6 Q4fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=i0nl/jN0f1cPv7NVqyCz/7CtUhBNEvsRU10K+y8txro=; b=tK8FehYI4oFnK2kLlBaWmrf6/YJvRxSfQxV8gRYawzs5aFC3IB9TEaEVEArMLUZoqj 7Heis2PlIfmylrXxXxs4LF/EtlyxKIKsc4BNsjoeu3wZrXY8BYQ2RQMOe0AfapN1jtLJ FLPCBljTKOzVXATgVmo1RDScZbjGpCiN2KFmpFRuvF66AAnpLIa24yO+9vblFueLTcUg Q+KeDktgI2BzhVnzJHhTdmKy1+CNc9/hCSRlQ6YLHZU7rPzjGUDEt+GnyRSTVYua38Tt BOzufPamVJ1FmeH8HA/w+ejPFy8bJUSyPEMv/5xiXuKbL7nYXmKp6QO4hXqlJ7JqXdvE TlQA== X-Gm-Message-State: AO0yUKWlmASzC92q9BqmJTBC5bexhlwLaDaSjhvzHHoYK/DG2Tc16KHQ P61r9/H3TPFVWICnsc0BciG5vafztP4= X-Google-Smtp-Source: AK7set/BIA6N49kPGoxv06lS7wCNWCELANbVwHKDfqc5jY4b/MPUsMPRo9xcXaPGQT9U6mInye22Gg== X-Received: by 2002:a05:6a21:300f:b0:bf:2c1:206c with SMTP id yd15-20020a056a21300f00b000bf02c1206cmr17779718pzb.13.1676271502896; Sun, 12 Feb 2023 22:58:22 -0800 (PST) Received: from ?IPV6:2601:681:8600:13d0::f0a? ([2601:681:8600:13d0::f0a]) by smtp.gmail.com with ESMTPSA id f5-20020a637545000000b0047917991e83sm6598901pgn.48.2023.02.12.22.58.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 12 Feb 2023 22:58:22 -0800 (PST) Message-ID: Date: Sun, 12 Feb 2023 23:58:21 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Subject: Re: [PATCH] lra: Replace subregs in bare uses & clobbers [PR108681] Content-Language: en-US To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com References: From: Jeff Law In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,KAM_SHORT,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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. > 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. > > 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