public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <law@redhat.com>
To: Ilya Enkovich <enkovich.gnu@gmail.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>, rdsandiford@googlemail.com
Subject: Re: [PATCH, PR target/65103, 2/3] Propagate address constants into loops for i386
Date: Thu, 28 May 2015 23:54:00 -0000	[thread overview]
Message-ID: <5567939F.9060507@redhat.com> (raw)
In-Reply-To: <CAMbmDYbcLiU5QcQ053RF9PofPZWxjdrfDTNWffpWZvnV9pzAOA@mail.gmail.com>

On 05/05/2015 05:05 AM, Ilya Enkovich wrote:
> 2015-04-21 8:52 GMT+03:00 Jeff Law <law@redhat.com>:
>> On 04/17/2015 02:34 AM, Ilya Enkovich wrote:
>>>
>>> On 15 Apr 14:07, Ilya Enkovich wrote:
>>>>
>>>> 2015-04-14 8:22 GMT+03:00 Jeff Law <law@redhat.com>:
>>>>>
>>>>> On 03/15/2015 02:30 PM, Richard Sandiford wrote:
>>>>>>
>>>>>>
>>>>>> Ilya Enkovich <enkovich.gnu@gmail.com> writes:
>>>>>>>
>>>>>>>
>>>>>>> This patch allows propagation of loop invariants for i386 if
>>>>>>> propagated
>>>>>>> value is a constant to be used in address operand.  Bootstrapped and
>>>>>>> tested on x86_64-unknown-linux-gnu.  OK for trunk or stage 1?
>>>>>>
>>>>>>
>>>>>>
>>>>>> Is it necessary for this to be a target hook?  The concept doesn't seem
>>>>>> particularly target-specific.  We should only propagate into the
>>>>>> address
>>>>>> if the new cost is no greater than the old cost, but if the address
>>>>>> meets that condition and if propagating at this point in the pipeline
>>>>>> is
>>>>>> a win on x86, then wouldn't it be a win for other targets too?
>>>>>
>>>>>
>>>>> I agree with Richard here.  I can't see a strong reason why this should
>>>>> be a
>>>>> target hook.
>>>>>
>>>>> Perhaps part of the issue here is the address costing metrics may not
>>>>> have
>>>>> enough context to make good decisions.  In which case what context do
>>>>> they
>>>>> need?
>>>>
>>>>
>>>> At this point I don't insist on a target hook.  The main reasoning was
>>>> to not affect other targets. If we extend propagation for non constant
>>>> values different aspects may appear. E.g. possible register pressure
>>>> changes may significantly affect ia32. I just wanted to have an
>>>> instrument to play with a propagation on x86 not affecting other
>>>> targets. I don't have an opportunity to test possible performance
>>>> implications on non-x86 targets. Don't expect (significant)
>>>> regressions there but who knows...
>>>>
>>>> I'll remove the hook from this patch. Will probably introduce it later
>>>> if some target specific cases are found.
>>>>
>>>> Thanks,
>>>> Ilya
>>>>
>>>>>
>>>>> Jeff
>>>
>>>
>>> Here is a version with no hook.  Bootstrapped and tested on
>>> x86_64-unknown-linux-gnu.  Is it OK for trunk?
>>>
>>> Thanks,
>>> Ilya
>>> --
>>> gcc/
>>>
>>> 2015-04-17  Ilya Enkovich  <ilya.enkovich@intel.com>
>>>
>>>          PR target/65103
>>>          * fwprop.c (forward_propagate_into): Propagate loop
>>>          invariants if a target says so.
>>>
>>> gcc/testsuite/
>>>
>>> 2015-04-17  Ilya Enkovich  <ilya.enkovich@intel.com>
>>>
>>>          PR target/65103
>>>          * gcc.target/i386/pr65103-2.c: New.
>>
>> It seems to me there's a key piece missing here -- metrics.
>>
>> When is this profitable, when is it not profitable.   Just blindly undoing
>> LICM seems wrong here.
>>
>> The first thought is to look at register pressure through the loop.  I
>> thought we had some infrastructure for this kind of query available. It'd
>> probably be wise to re-use it.  In fact, one might reasonably ask if LICM
>> should have hoisted the expression to start with.
>>
>>
>> I'd also think the cost of the constant may come into play here.  A really
>> cheap constant probably should not have been hoisted by LICM to start with
>> -- but the code may have been written in such a way that some low cost
>> constants are pulled out as loop invariants at the source level.  So this
>> isn't strictly an issue of un-doing bad LICM
>>
>> So I think to go forward we need to be working on solving the "when is this
>> a profitable transformation to make".
>
> This patch doesn't force propagation.  The patch just allows
> propagation and regular fwprop cost estimation is used to compute if
> this is profitable.  For i386 I don't see cases when we shouldn't
> propagate. We remove instruction, reduce register pressure and having
> constant in memory operand is free which is reflected in address_cost
> hook.
Right, but you're blindly propagating.  The right thing to do is look at 
some kind of metric to estimate when it's profitable to propagate the 
constant back in vs leave it hoisted out.

If you look at what Kugan is doing in cprop.c, that's exactly the 
approach he's taking -- looking at rtx costing to determine when to 
propagate the constant back into the loop.  It could probably be made 
better with some knowledge of register pressure and looking at whether 
or not all uses (vs just some uses) of the constant will be propagated.

Jeff

  parent reply	other threads:[~2015-05-28 22:16 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-10 15:00 Ilya Enkovich
2015-03-10 16:12 ` Ilya Enkovich
2015-03-15 20:30 ` Richard Sandiford
2015-03-17 19:13   ` Jeff Law
2015-04-14  5:22   ` Jeff Law
2015-04-15 11:07     ` Ilya Enkovich
2015-04-17  8:36       ` Ilya Enkovich
2015-04-21  6:45         ` Jeff Law
2015-05-05 11:05           ` Ilya Enkovich
2015-05-21 13:22             ` Ilya Enkovich
2015-05-28 23:54             ` Jeff Law [this message]
2015-06-01 12:26               ` Ilya Enkovich
2015-06-25 14:15                 ` Ilya Enkovich
2015-07-09 20:04                 ` Jeff Law

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=5567939F.9060507@redhat.com \
    --to=law@redhat.com \
    --cc=enkovich.gnu@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=rdsandiford@googlemail.com \
    /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).