From: Jeff Law <jeffreyalaw@gmail.com>
To: HAO CHEN GUI <guihaoc@linux.ibm.com>,
gcc-patches <gcc-patches@gcc.gnu.org>,
Segher Boessenkool <segher@kernel.crashing.org>,
David <dje.gcc@gmail.com>, "Kewen.Lin" <linkw@linux.ibm.com>,
Peter Bergner <bergner@linux.ibm.com>,
richard.sandiford@arm.com
Subject: Re: [PATCH-1v2] fwprop: Replace rtx_cost with insn_cost in try_fwprop_subst_pattern [PR113325]
Date: Wed, 5 Jun 2024 07:27:34 -0600 [thread overview]
Message-ID: <df3ed958-2328-4051-8299-37fea2925d21@gmail.com> (raw)
In-Reply-To: <mptplsvvjsa.fsf@arm.com>
On 6/5/24 3:08 AM, Richard Sandiford wrote:
> HAO CHEN GUI <guihaoc@linux.ibm.com> writes:
>> Hi,
>> This patch replaces rtx_cost with insn_cost in forward propagation.
>> In the PR, one constant vector should be propagated and replace a
>> pseudo in a store insn if we know it's a duplicated constant vector.
>> It reduces the insn cost but not rtx cost. In this case, the cost is
>> determined by destination operand (memory or pseudo). Unfortunately,
>> rtx cost can't help.
>>
>> The test case is added in the second target specific patch.
>> https://gcc.gnu.org/pipermail/gcc-patches/2024-January/643995.html
>>
>> Compared to previous version, the main change is not to do
>> substitution if either new or old insn cost is zero. The zero means
>> the cost is unknown.
>>
>> Previous version
>> https://gcc.gnu.org/pipermail/gcc-patches/2024-January/643994.html
>>
>> Bootstrapped and tested on x86 and powerpc64-linux BE and LE with no
>> regressions. Is it OK for the trunk?
>>
>> ChangeLog
>> fwprop: Replace set_src_cost with insn_cost in try_fwprop_subst_pattern
>>
>> gcc/
>> * fwprop.cc (try_fwprop_subst_pattern): Replace set_src_cost with
>> insn_cost.
>
> Thanks for doing this. It's definitely the right direction, but:
>
>> patch.diff
>> diff --git a/gcc/fwprop.cc b/gcc/fwprop.cc
>> index cb6fd6700ca..184a22678b7 100644
>> --- a/gcc/fwprop.cc
>> +++ b/gcc/fwprop.cc
>> @@ -470,21 +470,19 @@ try_fwprop_subst_pattern (obstack_watermark &attempt, insn_change &use_change,
>> redo_changes (0);
>> }
>>
>> - /* ??? In theory, it should be better to use insn costs rather than
>> - set_src_costs here. That would involve replacing this code with
>> - change_is_worthwhile. */
>
> ...as hinted at in the comment, rtl-ssa already has a routine for
> insn_cost-based calculations. It has two (supposed) advantages:
> it caches the old costs, and it takes execution frequency into
> account when optimising for speed.
>
> The comment is out of date though. The name of the routine is
> changes_are_worthwhile rather than change_is_worthwhile. Could you
> try using that instead?
Funny, I went wandering around looking for that function to see how it
was implemented and how it might compare to what was being proposed.
Of course I never found it, even after rewinding to various old git
hashes that looked promising.
So, yea, definitely would prefer re-using changes_are_worthwhile if it
works reasonably well for the issue at hand.
jeff
prev parent reply other threads:[~2024-06-05 13:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-10 5:43 HAO CHEN GUI
2024-06-05 9:08 ` Richard Sandiford
2024-06-05 13:27 ` Jeff Law [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=df3ed958-2328-4051-8299-37fea2925d21@gmail.com \
--to=jeffreyalaw@gmail.com \
--cc=bergner@linux.ibm.com \
--cc=dje.gcc@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=guihaoc@linux.ibm.com \
--cc=linkw@linux.ibm.com \
--cc=richard.sandiford@arm.com \
--cc=segher@kernel.crashing.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).