From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by sourceware.org (Postfix) with ESMTPS id C9F0E3858D33 for ; Mon, 28 Aug 2023 23:33:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C9F0E3858D33 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-pf1-x431.google.com with SMTP id d2e1a72fcca58-68c0d886ea0so2535406b3a.2 for ; Mon, 28 Aug 2023 16:33:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693265622; x=1693870422; 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=HQcnB7NUakH2aG1+OaH8u5itFOgCayzIH3EwzXY7qVQ=; b=E50H6Dso2zT6SDLhmAoh7v9sCsMHbPn30ZZNnAl2hRgohHbm1eM3hhAJdCnKtHdr4R 93b3A73s64Ddu8119X5poOeOyUKXF2y8y9U+S07Nz64Iy6ittOX8laKdVknx6YP4gRJf bM8DigQ1FwkXNqVp2XSwbpsGSSEdNTaEYsBiZWFr6/5p4X6rA7wQWpGXsY3OjQJ1FpqE WKLzZgFIFv2L+rp6u/72FmkRzUCh2un4cWruS06K7a10Z893qcs1F1lL9/9mA0wKicgn dZzDJp4pE/HLmgnZOEVeWTBVRamnH559BYNiPWXoTBpjufdKAlIYlWChWzaR532HwTMc 7oDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693265622; x=1693870422; 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=HQcnB7NUakH2aG1+OaH8u5itFOgCayzIH3EwzXY7qVQ=; b=EtK0G7KgUZrCsw1Vl4GKGWlElTuhtxSBKyMajbqTnEfxdvI+WrRc9+x41Wa779bAAE icvXEDyZlwHyMwZH6Mf2jumRy7yW5/isbcsIljnSj2SS2eh4urJfShlJTeFjjm5HMJMP I4fI8zR3KRIaR9wGGTvNCEnolQahDArvcBHnXyEHTZeq7YA/sJSZCLqZEidoGc/NCQVz KoEBspQExoaTfz+wO2RsbIxgTE1mvzcnCL2xzyYM2/mTGD9pCsu3Qs7SydGDCRAUupR/ ex+BczBRUUUan+9tN9kz33/4W4evD9CMs+yVdWmn6XwAqPack0aLfUSFcw3kazgc4mEp 2W+w== X-Gm-Message-State: AOJu0YxvoYs2oY+fv/WS726SabfgBcPf6qy1qRUHOTm1ljMu9z8L77H5 ZdMUqx0p1vSP8vyXIII3F2BkaR3t3uw= X-Google-Smtp-Source: AGHT+IGdHYsVPXruU67HEAam+8mPQhniEcvIjxgSSavjWEZuRMY2l7Zfz+24dg1riCrr/PLkshc7sg== X-Received: by 2002:a05:6a20:96d8:b0:14d:f087:c0cc with SMTP id hq24-20020a056a2096d800b0014df087c0ccmr2129633pzc.48.1693265621596; Mon, 28 Aug 2023 16:33:41 -0700 (PDT) Received: from [172.31.0.109] ([136.36.130.248]) by smtp.gmail.com with ESMTPSA id d12-20020a056a00198c00b0066a4e561beesm937413pfl.173.2023.08.28.16.33.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 28 Aug 2023 16:33:40 -0700 (PDT) Message-ID: <48bed106-190e-ab5f-4099-fdfd4f5a193f@gmail.com> Date: Mon, 28 Aug 2023 17:33:39 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH] fwprop: Allow UNARY_P and check register pressure. Content-Language: en-US To: Robin Dapp , gcc-patches , "richard.sandiford" References: <5a90c8a9-1570-5af4-bfdc-19d097bfee6e@gmail.com> <9acc1a24-5d01-40ad-b4b2-5948585d3e8c@gmail.com> From: Jeff Law In-Reply-To: <9acc1a24-5d01-40ad-b4b2-5948585d3e8c@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.5 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 8/24/23 08:06, Robin Dapp via Gcc-patches wrote: > Ping. I refined the code and some comments a bit and added a test > case. > > My question in general would still be: Is this something we want > given that we potentially move some of combine's work a bit towards > the front of the RTL pipeline? > > Regards > Robin > > Subject: [PATCH] fwprop: Allow UNARY_P and check register pressure. > > This patch enables the forwarding of UNARY_P sources. As this > involves potentially replacing a vector register with a scalar register > the ira_hoist_pressure machinery is used to calculate the change in > register pressure. If the propagation would increase the pressure > beyond the number of hard regs, we don't perform it. > > gcc/ChangeLog: > > * fwprop.cc (fwprop_propagation::profitable_p): Add unary > handling. > (fwprop_propagation::update_register_pressure): New function. > (fwprop_propagation::register_pressure_high_p): New function > (reg_single_def_for_src_p): Look through unary expressions. > (try_fwprop_subst_pattern): Check register pressure. > (forward_propagate_into): Call new function. > (fwprop_init): Init register pressure. > (fwprop_done): Clean up register pressure. > (fwprop_insn): Add comment. > > gcc/testsuite/ChangeLog: > > * gcc.target/riscv/rvv/autovec/binop/vadd-vx-fwprop.c: New test. So I was hoping that Richard S. would chime in here as he knows this code better than anyone. This looks like a much better implementation of something I've done before :-) Basically imagine a target where a sign/zero extension can be folded into arithmetic for free. We put in various hacks to this code to encourage more propagations of extensions. I still think this is valuable. As we lower from gimple->RTL we're going to still have artifacts in the RTL that we're going to want to optimize away. fwprop has certain advantages over combine, including the fact that it runs earlier, pre-loop. It looks generally sensible to me. But give Richard S. another week to chime in. He seems to be around, but may be slammed with stuff right now. jeff