public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Sandiford <richard.sandiford@arm.com>
To: "juzhe.zhong\@rivai.ai" <juzhe.zhong@rivai.ai>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>,  rguenther <rguenther@suse.de>
Subject: Re: [PATCH V7] VECT: Add decrement IV support in Loop Vectorizer
Date: Tue, 16 May 2023 07:57:12 +0100	[thread overview]
Message-ID: <mpth6sc4vcn.fsf@arm.com> (raw)
In-Reply-To: <F99B5327DA7207C5+202305161232591637457@rivai.ai> (juzhe's message of "Tue, 16 May 2023 12:32:59 +0800")

"juzhe.zhong@rivai.ai" <juzhe.zhong@rivai.ai> writes:
>>> The examples are good, but this one made me wonder: why is the
>>> adjustment made to the limit (namely 16, the gap between _39 and _41)
>>> different from the limits imposed by the MIN_EXPR (32)?  And I think
>>> the answer is that:
>
>>> - _47 counts the number of elements processed by the loop in total,
>>>   including the vectors under the control of _44
>
>>> - _44 counts the number of elements controlled by _47 in the next
>>>   iteration of the vector loop (if there is one)
>
>>> And that's needed to allow the IVs to be updated independently.
>
>>> The difficulty with this is that the len_load* and len_store*
>>> optabs currently say that the behaviour is undefined if the
>>> length argument is greater than the length of a vector.
>>> So I think using these values of _47 and _44 in the .LEN_STOREs
>>> is relying on undefined behaviour.
>
>>> Haven't had time to think about the consequences of that yet,
>>> but wanted to send something out sooner rather than later.
>
> Hi, Richard. I totally understand your concern now. I think the undefine behavior is more
> appropriate for RVV since we have vsetvli instruction that gurantee this will cause potential
> issues. However, for some other target, we may need to use additional MIN_EXPR to guard
> the length never over VF. I think it can be addressed in the future when it is needed.

But we can't generate (vector) gimple that has undefined behaviour from
(scalar) gimple that had defined behaviour.  So something needs to change.
Either we need to generate a different sequence, or we need to define
what the behaviour of len_load/store/etc. are when the length is out of
range (perhaps under a target hook?).

We also need to be consistent.  If case 2 is allowed to use length
parameters that are greater than the vector length, then there's no
reason for case 1 to use the result of the MIN_EXPR as the length
parameter.  It could just use the loop IV directly.  (I realise the
select_vl patch will change case 1 for RVV anyway.  But the principle
still holds.)

What does the riscv backend's implementation of the len_load and
len_store guarantee?  Is any length greater than the vector length
capped to the vector length?  Or is it more complicated than that?

Thanks,
Richard

  reply	other threads:[~2023-05-16  6:57 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-15  1:28 juzhe.zhong
2023-05-15 19:44 ` Richard Sandiford
2023-05-15 21:20   ` 钟居哲
2023-05-16  4:32   ` juzhe.zhong
2023-05-16  6:57     ` Richard Sandiford [this message]
2023-05-16  7:22       ` juzhe.zhong
2023-05-16  7:35       ` juzhe.zhong
2023-05-16  7:39       ` juzhe.zhong
2023-05-16  8:16         ` Richard Sandiford
2023-05-16  8:23           ` juzhe.zhong
2023-05-16  8:30             ` Richard Sandiford
2023-05-16  9:25               ` juzhe.zhong
2023-05-16 10:25               ` juzhe.zhong
2023-05-16 11:23               ` juzhe.zhong

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=mpth6sc4vcn.fsf@arm.com \
    --to=richard.sandiford@arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=juzhe.zhong@rivai.ai \
    --cc=rguenther@suse.de \
    /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).