public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: sellcey@imgtec.com
Cc: GCC Patches <gcc-patches@gcc.gnu.org>,
	amker cheng <amker.cheng@gmail.com>
Subject: Re: [RFC] Request for comments on ivopts patch
Date: Mon, 14 Dec 2015 08:57:00 -0000	[thread overview]
Message-ID: <CAFiYyc0AfHE5Vqvtz0RWRrp2nn3=x_LDD2UmFwOZe9f4r4CcGg@mail.gmail.com> (raw)
In-Reply-To: <1449877714.4788.113.camel@ubuntu-sellcey>

On Sat, Dec 12, 2015 at 12:48 AM, Steve Ellcey <sellcey@imgtec.com> wrote:
> On Wed, 2015-12-09 at 11:24 +0100, Richard Biener wrote:
>
>> > This second case (without the preference for the original IV)
>> > generates better code on MIPS because the final assembly
>> > has the increment instructions between the loads and the tests
>> > of the values being loaded and so there is no delay (or less delay)
>> > between the load and use.  It seems like this could easily be
>> > the case for other platforms too so I was wondering what people
>> > thought of this patch:
>>
>> You don't comment on the comment you remove ... debugging
>> programs is also important!
>>
>> So if then the cost of both cases should be distinguished
>> somewhere else, like granting a bonus for increment before
>> exit test or so.
>>
>> Richard.
>
> Here is new patch that tries to do that.  It accomplishes the same thing
> as my original patch but by checking different features.  Basically, for
> machines with no autoinc/autodec it has a preference for IVs that don't
> change during loop (i.e. var_before == var_after).
>
> What do you think about this approach?
>
> Steve Ellcey
> sellcey@imgtec.com
>
>
> 2015-12-11  Steve Ellcey  <sellcey@imgtec.com>
>
>         * tree-ssa-loop-ivopts.c (determine_iv_cost): Add cost to ivs that
>         need to be updated during loop.
>
>
> diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c
> index 98dc451..ecf9737 100644
> --- a/gcc/tree-ssa-loop-ivopts.c
> +++ b/gcc/tree-ssa-loop-ivopts.c
> @@ -5826,6 +5826,14 @@ determine_iv_cost (struct ivopts_data *data, struct iv_cand *cand)
>        || DECL_ARTIFICIAL (SSA_NAME_VAR (cand->var_before)))
>      cost++;
>
> +  /* If we are not using autoincrement or autodecrement, prefer ivs that
> +     do not have to be incremented/decremented during the loop.  This can
> +     move loads ahead of the instructions that update the address.  */
> +  if (cand->pos != IP_BEFORE_USE
> +      && cand->pos != IP_AFTER_USE
> +      && cand->var_before != cand->var_after)
> +    cost++;
> +

I don't know enough to assess the effect of this but

 1) not all archs can do auto-incdec so either the comment is misleading
or the test should probably be amended
 2) I wonder why with the comment ("during the loop") you exclude IP_NORMAL/END

that said, the comment needs to explain the situation better.

Of course all such patches need some code-gen effect investigation
on more than one arch.

[I wonder if a IV cost adjust target hook makes sense at some point]

Richard.

>    /* Prefer not to insert statements into latch unless there are some
>       already (so that we do not create unnecessary jumps).  */
>    if (cand->pos == IP_END
>
>

  reply	other threads:[~2015-12-14  8:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-08 18:56 Steve Ellcey 
2015-12-09 10:24 ` Richard Biener
2015-12-11 23:48   ` Steve Ellcey
2015-12-14  8:57     ` Richard Biener [this message]
2015-12-14 23:06       ` Steve Ellcey
2015-12-16 13:43         ` Richard Biener

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='CAFiYyc0AfHE5Vqvtz0RWRrp2nn3=x_LDD2UmFwOZe9f4r4CcGg@mail.gmail.com' \
    --to=richard.guenther@gmail.com \
    --cc=amker.cheng@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=sellcey@imgtec.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).