public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/112331] New: middle-end: Fail vectorization
@ 2023-11-01  9:20 juzhe.zhong at rivai dot ai
  2023-11-01  9:24 ` [Bug c/112331] " 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-01  9:20 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 112331
           Summary: middle-end: Fail vectorization
           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: ---

https://gcc.godbolt.org/z/x7GGzezGh


#include <stdio.h>
#define LEN 32000
#define ntimes 200000
#define TYPE float
#define lll LEN
#define LEN2 256
#define ALIGNMENT 16
__attribute__ ((aligned(ALIGNMENT))) TYPE X[lll],Y[lll],Z[lll],U[lll],V[lll];

struct GlobalData {
  __attribute__((aligned(ALIGNMENT))) TYPE a[LEN];
  int pad1[3];
  __attribute__((aligned(ALIGNMENT))) TYPE b[LEN];
  int pad2[5];
  __attribute__((aligned(ALIGNMENT))) TYPE c[LEN];
  int pad3[7];
  __attribute__((aligned(ALIGNMENT))) TYPE d[LEN];
  int pad4[11];
  __attribute__((aligned(ALIGNMENT))) TYPE e[LEN];

  int pad5[13];
  __attribute__((aligned(ALIGNMENT))) TYPE aa[LEN2][LEN2];
  int pad6[17];
  __attribute__((aligned(ALIGNMENT))) TYPE bb[LEN2][LEN2];
  int pad7[19];
  __attribute__((aligned(ALIGNMENT))) TYPE cc[LEN2][LEN2];
  int pad8[23];
  __attribute__((aligned(ALIGNMENT))) TYPE tt[LEN2][LEN2];
} global_data;

__attribute__((aligned(ALIGNMENT))) TYPE * const a = global_data.a;
__attribute__((aligned(ALIGNMENT))) TYPE * const b = global_data.b;
__attribute__((aligned(ALIGNMENT))) TYPE * const c = global_data.c;
__attribute__((aligned(ALIGNMENT))) TYPE * const d = global_data.d;
__attribute__((aligned(ALIGNMENT))) TYPE * const e = global_data.e;
__attribute__((aligned(ALIGNMENT))) TYPE (* const aa)[LEN2] = global_data.aa;
__attribute__((aligned(ALIGNMENT))) TYPE (* const bb)[LEN2] = global_data.bb;
__attribute__((aligned(ALIGNMENT))) TYPE (* const cc)[LEN2] = global_data.cc;
__attribute__((aligned(ALIGNMENT))) TYPE (* const tt)[LEN2] = global_data.tt;

int foo()
{

//      linear dependence testing
//      no dependence - vectorizable


        for (int nl = 0; nl < 2*ntimes; nl++) {
//              #pragma vector always
                for (int i = 1; i < LEN; i += 2) {
                        a[i] = a[i - 1] + b[i];
                }
        }

        return 0;
}

Both RVV and ARM SVE faild to vectorize it wheras Clang can vectorize it.

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

end of thread, other threads:[~2023-11-02 10:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-01  9:20 [Bug c/112331] New: middle-end: Fail vectorization juzhe.zhong at rivai dot ai
2023-11-01  9:24 ` [Bug c/112331] " juzhe.zhong at rivai dot ai
2023-11-02  7:42 ` [Bug tree-optimization/112331] " juzhe.zhong at rivai dot ai
2023-11-02 10:00 ` [Bug tree-optimization/112331] Fail vectorization after loop interchange rguenth at gcc dot gnu.org
2023-11-02 10:14 ` juzhe.zhong at rivai dot ai
2023-11-02 10:48 ` 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).