public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <rguenther@suse.de>
To: Richard Sandiford <richard.sandiford@arm.com>
Cc: "Kewen.Lin" <linkw@linux.ibm.com>,
	 "juzhe.zhong@rivai.ai" <juzhe.zhong@rivai.ai>,
	 gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: decremnt IV patch create fails on PowerPC
Date: Tue, 30 May 2023 10:43:34 +0000 (UTC)	[thread overview]
Message-ID: <nycvar.YFH.7.77.849.2305301039460.4723@jbgna.fhfr.qr> (raw)
In-Reply-To: <mpt5y8a9lgp.fsf@arm.com>

On Tue, 30 May 2023, Richard Sandiford wrote:

> My understanding was that we went into this knowing that the IVs
> would defeat SCEV analysis.  Apparently that wasn't a problem for RVV,
> but it's not surprising that it is a problem in general.
> 
> This isn't just about SELECT_VL though.  We use the same type of IV
> for cases what aren't going to use SELECT_VL.
> 
> Richard Biener <rguenther@suse.de> writes:
> > On Tue, 30 May 2023, Kewen.Lin wrote:
> >
> >> on 2023/5/30 17:26, juzhe.zhong@rivai.ai wrote:
> >> > Ok.
> >> > 
> >> > It seems that for this conditions:
> >> > 
> >> > +  /* If we're vectorizing a loop that uses length "controls" and
> >> > +     can iterate more than once, we apply decrementing IV approach
> >> > +     in loop control.  */
> >> > +  if (LOOP_VINFO_CAN_USE_PARTIAL_VECTORS_P (loop_vinfo)
> >> > +      && !LOOP_VINFO_LENS (loop_vinfo).is_empty ()
> >> > +      && LOOP_VINFO_PARTIAL_LOAD_STORE_BIAS (loop_vinfo) == 0
> >> > +      && !(LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo)
> >> > +	   && known_le (LOOP_VINFO_INT_NITERS (loop_vinfo),
> >> > +			LOOP_VINFO_VECT_FACTOR (loop_vinfo))))
> >> > +    LOOP_VINFO_USING_DECREMENTING_IV_P (loop_vinfo) = true;
> >> > 
> >> > 
> >> > I should add direct_supportted_p (SELECT_VL...) to this is that right?
> >> 
> >> I guess no, with this condition any targets without SELECT_VL are unable
> >> to leverage the new decrement scheme for lengths, as your reply in PR109971
> >> you didn't meant to disable it.  IIUC, what Richi suggested is to introduce
> >> one new IV just like the previous one which has non-variable step, then it's
> >> SCEV-ed and some analysis based on it can do a good job.
> >
> > No, I said the current scheme does sth along
> >
> >  do {
> >    remain -= MIN (vf, remain);
> >  } while (remain != 0);
> >
> > and I suggest to instead do
> >
> >  do {
> >    old_remain = remain;
> >    len = MIN (vf, remain);
> >    remain -= vf;
> >  } while (old_remain >= vf);
> >
> > basically since only the last iteration will have len < vf we can
> > ignore that remain -= vf will underflow there if we appropriately
> > rewrite the exit test to use the pre-decrement value.
> 
> Yeah, agree that should work.

Btw, it's still on my TOOD list (unless somebody beats me...) to
rewrite the vectorizer code gen to do all loop control and conditions
on a decrementing "remaining scalar iters" IV.

> But how easy would it be to extend SCEV analysis, via a pattern match?
> The evolution of the IV phi wrt the inner loop is still a normal SCEV.

No, the IV isn't a normal SCEV, the final value is different.
I think pattern matching this in niter analysis could work though.

Richard.

  reply	other threads:[~2023-05-30 10:43 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-25 22:45 钟居哲
2023-05-26  6:46 ` Richard Biener
2023-05-26  7:46   ` juzhe.zhong
2023-05-30  9:22     ` Richard Biener
2023-05-30  9:26       ` juzhe.zhong
2023-05-30  9:50         ` Richard Biener
2023-05-30  9:55           ` juzhe.zhong
2023-05-30 11:30           ` juzhe.zhong
2023-05-30  9:51         ` Kewen.Lin
2023-05-30 10:00           ` Richard Biener
2023-05-30 10:05             ` juzhe.zhong
2023-05-30 10:12             ` Richard Sandiford
2023-05-30 10:43               ` Richard Biener [this message]
2023-05-30 11:29                 ` Richard Sandiford
2023-05-30 11:37                   ` 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=nycvar.YFH.7.77.849.2305301039460.4723@jbgna.fhfr.qr \
    --to=rguenther@suse.de \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=juzhe.zhong@rivai.ai \
    --cc=linkw@linux.ibm.com \
    --cc=richard.sandiford@arm.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).