From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C0D803858D20; Wed, 1 Nov 2023 09:20:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C0D803858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1698830434; bh=6UQkuwcUs9UDhVlp1eGD9TpswVkp5EV/ZVAod9cgktw=; h=From:To:Subject:Date:From; b=OOcrgMpdXd9TppVM/W0Ij+iQfYpAHpYI97BcsqDWHpqcc+Dnib9MmYZl2CWsxnGDx ExOB+EWCbtMYS0edqS+PhcHlqFhCIUIiM2VbGNYWaeedunpHwHajjbruFpIoBJcSGq D85/GsJ8SYYqtgzsSCHZvjTMQxQeIpjnA/FZnwEE= From: "juzhe.zhong at rivai dot ai" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/112331] New: middle-end: Fail vectorization Date: Wed, 01 Nov 2023 09:20:33 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: juzhe.zhong at rivai dot ai X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D112331 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 #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 =3D global_data.a; __attribute__((aligned(ALIGNMENT))) TYPE * const b =3D global_data.b; __attribute__((aligned(ALIGNMENT))) TYPE * const c =3D global_data.c; __attribute__((aligned(ALIGNMENT))) TYPE * const d =3D global_data.d; __attribute__((aligned(ALIGNMENT))) TYPE * const e =3D global_data.e; __attribute__((aligned(ALIGNMENT))) TYPE (* const aa)[LEN2] =3D global_data= .aa; __attribute__((aligned(ALIGNMENT))) TYPE (* const bb)[LEN2] =3D global_data= .bb; __attribute__((aligned(ALIGNMENT))) TYPE (* const cc)[LEN2] =3D global_data= .cc; __attribute__((aligned(ALIGNMENT))) TYPE (* const tt)[LEN2] =3D global_data= .tt; int foo() { // linear dependence testing // no dependence - vectorizable for (int nl =3D 0; nl < 2*ntimes; nl++) { // #pragma vector always for (int i =3D 1; i < LEN; i +=3D 2) { a[i] =3D a[i - 1] + b[i]; } } return 0; } Both RVV and ARM SVE faild to vectorize it wheras Clang can vectorize it.=