public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "juzhe.zhong at rivai dot ai" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/113134] gcc does not version loops with early break conditions that don't have side-effects
Date: Thu, 28 Dec 2023 04:51:27 +0000	[thread overview]
Message-ID: <bug-113134-4-WrhdShNtUk@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-113134-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113134

--- Comment #14 from JuzheZhong <juzhe.zhong at rivai dot ai> ---
(In reply to Tamar Christina from comment #13)
> (In reply to JuzheZhong from comment #12)
> > (In reply to Tamar Christina from comment #11)
> > > (In reply to JuzheZhong from comment #10)
> > > > (In reply to Tamar Christina from comment #9)
> > > > > (In reply to JuzheZhong from comment #8)
> > > > > > Suppose the loop mask is generated by whilelo instruction of ARM SVE.
> > > > > > 
> > > > > > Suppose we have 8 elements in a single whole vector.
> > > > > > 
> > > > > > mask = whilo (0, res) if res = 6, then mask = 11111000.
> > > > > > data = 12345678
> > > > > > 
> > > > > > Then if it is early break. You are reversing both data and mask as follows:
> > > > > > 
> > > > > > new_mask = 00011111
> > > > > > new_data = 87654321
> > > > > > 
> > > > > > Then use the EXTRACT_LAST, we will get value = 1 for early break.
> > > > > > 
> > > > > > Am I right ?
> > > > > 
> > > > > Yeah, the idea being the scalar loop will then run from 1 to 6 to do any
> > > > > side effects that we couldn't apply.
> > > > > 
> > > > > We went with this approach first because it works for non-masked
> > > > > architectures too. In GCC-15 we'll try to implement staying entirely inside
> > > > > a vector loop by splitting the mask in elements until first active and
> > > > > element from first active so we can correctly mask the operations.
> > > > 
> > > > Ok. For the current approach. Isn't it the first element is always element 0
> > > > ?
> > > > 
> > > > Since for ARM SVE loop mask is generated by whilelo instructions, it always
> > > > set
> > > > mask bit from 0 to the last active element - 1.
> > > 
> > > sure, but you can't use BIT_FIELD_REF on VLA vectors.
> > 
> > So, for length partial vector. We can use VEC_EXTRACT with index = 0 since
> > VEC_EXTRACT optab allows VLA vectors now for length target.
> 
> Sounds good :)

I wonder whether ARM SVE can also use this approach VEC_EXTRACT with index = 0.

I guess the only issue is that when mask = all zero. That is, there is no
active elements, What behavior should be here for early break ?

  parent reply	other threads:[~2023-12-28  4:51 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-25 11:29 [Bug c/113134] New: Middle end early break vectorization: Fail to vectorize a simple early break code juzhe.zhong at rivai dot ai
2023-12-25 12:35 ` [Bug c/113134] " tnfchris at gcc dot gnu.org
2023-12-27 15:21 ` [Bug c/113134] gcc does not version loops with side-effect early breaks tnfchris at gcc dot gnu.org
2023-12-28  1:21 ` [Bug c/113134] gcc does not version loops with early break conditions that don't have side-effects juzhe.zhong at rivai dot ai
2023-12-28  3:48 ` tnfchris at gcc dot gnu.org
2023-12-28  3:55 ` juzhe.zhong at rivai dot ai
2023-12-28  4:02 ` tnfchris at gcc dot gnu.org
2023-12-28  4:05 ` tnfchris at gcc dot gnu.org
2023-12-28  4:23 ` juzhe.zhong at rivai dot ai
2023-12-28  4:30 ` tnfchris at gcc dot gnu.org
2023-12-28  4:35 ` juzhe.zhong at rivai dot ai
2023-12-28  4:45 ` tnfchris at gcc dot gnu.org
2023-12-28  4:46 ` juzhe.zhong at rivai dot ai
2023-12-28  4:49 ` tnfchris at gcc dot gnu.org
2023-12-28  4:51 ` juzhe.zhong at rivai dot ai [this message]
2023-12-28  4:53 ` tnfchris at gcc dot gnu.org
2023-12-28  5:08 ` tnfchris at gcc dot gnu.org
2023-12-28  9:11 ` juzhe.zhong at rivai dot ai
2023-12-28 21:20 ` [Bug tree-optimization/113134] " pinskia at gcc dot gnu.org
2024-01-08  8:11 ` rguenth at gcc dot gnu.org
2024-01-31 11:48 ` juzhe.zhong at rivai dot ai
2024-01-31 12:04 ` rguenth at gcc dot gnu.org
2024-02-02  3:38 ` juzhe.zhong at rivai dot ai
2024-02-02  8:49 ` juzhe.zhong at rivai dot ai

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=bug-113134-4-WrhdShNtUk@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).