public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Sebastian Pop <sebpop@gmail.com>
To: Richard Biener <richard.guenther@gmail.com>
Cc: Jeff Law <law@redhat.com>, Alan Lawrence <alan.lawrence@arm.com>,
		Abe Skolnik <a.skolnik@samsung.com>,
	"gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: Re: fix PR46029: reimplement if conversion of loads and stores
Date: Thu, 25 Jun 2015 14:28:00 -0000	[thread overview]
Message-ID: <CAFk3UF9O9PK8+ctcAB49sMduW7wDmM4R4=TgdYiFxS5pBH6V4w@mail.gmail.com> (raw)
In-Reply-To: <CAFiYyc3zhrwcXn2=PgJua4=k6XtJsan_WGAtvbw7fz7kSAkSRg@mail.gmail.com>

On Thu, Jun 25, 2015 at 4:43 AM, Richard Biener
<richard.guenther@gmail.com> wrote:
> when the new scheme triggers vectorization cannot succeed on the
> result as we get
>
>   if (cond)
>     *p = val;
>
> if-converted to
>
>   tem = cond ? p : &scratch;
>   *tem = val;

That's correct.

>
> and
>
>    if (cond)
>      val = *p;
>
> if-converted to
>
>   scatch = val;
>   tem = cond ? p : &scratch;
>   val = *tem;

The patch does this slightly differently:

   tem = cond ? p : &scratch;
   val = cond ? *tem : val;

I think I like your version better as it has only one cond_expr.

>
> and thus the store and loads appear as scather/gather ones to
> the vectorizer (if-conversion could directly generate masked
> load/stores of course and not use a scratch-pad at all in that case).
>
> So the question is whether we get more non-vectorized if-converted
> code out of this

this is the case.

> (and thus whether we want to use
> --param allow-store-data-races to get the old code back which is
> nicer to less capable CPUs and probably faster than using
> scatter/gather or masked loads/stores).

A flag to allow load and store data-races is an interesting suggestion.

Abe also suggested to continue optimizing the other way in cases
where we know to write or load from the same location on all branches:

if (c)
  A[i] = ...
else
  A[i] = ...

> scatter support is still not implemented in the vectorizer.

Correct.

> I also wonder if we should really care about load data races
> (not sure your patch does).

The patch does both loads and stores.

> I didn't look at the patch in detail yet - please address Alans comments
> and re-post an updated patch.
>
> In general I like the idea.

Thanks for your review,
Sebastian

>
> Thanks,
> Richard.
>
>>>
>>>
>>> Re. creation of scratchpads:
>>>     (1) Should the '64' byte size be the result of scanning the
>>> function, for the largest data size to which we store? (ideally,
>>> conditionally store!)
>>
>> I suspect most functions have conditional stores, but far fewer have
>> conditional stores that we'd like to if-convert.  ISTM that if we can lazily
>> allocate the scratchpad that'd be best.   If this were an RTL pass, then I'd
>> say query the backend for the widest mode store insn and use that to size
>> the scratchpad.  We may have something similar we can do in gimple without
>> resorting querying insn backend capabilities. Perhaps walking the in-scope
>> addressable variables or somesuch.
>>
>>
>>>     (2) Allocating only once per function: if we had one scratchpad per
>>> loop, it could/would live inside the test of "gimple_build_call_internal
>>> (IFN_LOOP_VECTORIZED, ...". Otherwise, if we if-convert one or more
>>> loops in the function, but then fail to vectorize them, we'll leave the
>>> scratchpad around for later phases to clean up. Is that OK?
>>
>> If the scratchpad is local to a function, then I'd expect we'd clean it up
>> just like any other unused local.  Once it's a global, then all bets are
>> off.
>>
>> Anyway, I probably should just look at the patch before making more
>> comments.
>>
>> jeff
>>

  reply	other threads:[~2015-06-25 14:15 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-12 21:05 Abe Skolnik
2015-06-22 16:31 ` Alan Lawrence
2015-06-24 17:11   ` Jeff Law
2015-06-25  9:48     ` Richard Biener
2015-06-25 14:28       ` Sebastian Pop [this message]
2015-06-26 12:35         ` Alan Lawrence
2015-06-26 15:10           ` Richard Biener
2015-06-26 21:29             ` Jeff Law
2015-07-06 20:46       ` Jeff Law
2015-06-24 16:51 ` Ramana Radhakrishnan
2015-06-24 17:02   ` Jeff Law
     [not found] <001301d0ae99$0f015800$2d040800$@samsung.com>
     [not found] ` <682387955.453848.1435166632115.JavaMail.yahoo@mail.yahoo.com>
     [not found]   ` <680180205.479081.1435168382362.JavaMail.yahoo@mail.yahoo.com>
2015-06-30  9:36     ` Alan Lawrence
2015-07-07 21:23 Abe
2015-07-08  9:14 ` Alan Lawrence
2015-07-08 15:52   ` Abe
2015-07-08  9:56 ` Richard Biener
2015-07-08 16:27   ` Abe

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='CAFk3UF9O9PK8+ctcAB49sMduW7wDmM4R4=TgdYiFxS5pBH6V4w@mail.gmail.com' \
    --to=sebpop@gmail.com \
    --cc=a.skolnik@samsung.com \
    --cc=alan.lawrence@arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=law@redhat.com \
    --cc=richard.guenther@gmail.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).