public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/112457] New: Possible better vectorization of different reduction min/max reduction
@ 2023-11-09 12:27 juzhe.zhong at rivai dot ai
  2023-11-09 12:29 ` [Bug c/112457] " juzhe.zhong at rivai dot ai
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: juzhe.zhong at rivai dot ai @ 2023-11-09 12:27 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 112457
           Summary: Possible better vectorization of different reduction
                    min/max reduction
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: juzhe.zhong at rivai dot ai
  Target Milestone: ---

Hi, Richard.

GCC-14 almost has all features of RVV.

I am planning to participate on improving GCC loop vectorizer in GCC-15.

Fix FAILs of TSVC is one of my plan.

Currently we can vectorize this following case:

int idx = 0;
int max = 0;
void foo (int n, int * __restrict a){
for (int i = 0; i < n; ++i) {
  max = max < a[i] ? a[i] : max;
}
}

However, if we change this case it failed:

void foo2 (int n, int * __restrict a){
for (int i = 0; i < n; ++i) {
  if (max < a[i]) {
    max = a[i];
  } else
    max = max;
}
}

Now, I notice another interesting and possible vectorization enhancement which
inspired by this patch of LLVM:
https://reviews.llvm.org/D143465

And more advance case is which is case from LLVM patch:
which is vectorization reduction with index:

void foo3 (int n, int * __restrict a){
for (int i = 0; i < n; ++i) {
  if (max < a[i]) {
    idx = i;
    max = a[i];
  }
}
}

I wonder it is a valuable optimization ? If yes, it would be one of my TODO
list.

Thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-01-08  9:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-09 12:27 [Bug c/112457] New: Possible better vectorization of different reduction min/max reduction juzhe.zhong at rivai dot ai
2023-11-09 12:29 ` [Bug c/112457] " juzhe.zhong at rivai dot ai
2023-11-09 12:45 ` [Bug tree-optimization/112457] " rguenth at gcc dot gnu.org
2024-01-02  8:58 ` juzhe.zhong at rivai dot ai
2024-01-02 16:03 ` xry111 at gcc dot gnu.org
2024-01-08  9:00 ` rguenth at gcc dot gnu.org

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).