https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103076
Bug ID: 103076
Summary: slp vectorizer failed to try smaller lenth.
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: crazylht at gmail dot com
Target Milestone: ---
Host: x86_64-pc-linux-gnu
Target: s390x-ibm-linux-gnu
struct Ax
{
int n;
short a[4];
};
void
foo4_2 (struct Ax *p)
{
p->a[0] = 0;
p->a[1] = 1;
p->a[2] = 2;
p->a[3] = 3;
}
Struct is 4-byte aligned, and gcc failed to vectorize it since s390 backend
doesn't support unaligned vector(4) short store. But it can be splitted into 2
vector(2) short store, i.e.
struct Ax
{
int n;
short a[4];
};
void
foo4_2 (struct Ax *p)
{
p->a[0] = 0;
p->a[1] = 1;
}
void
foo4_3 (struct Ax *p)
{
p->a[2] = 2;
p->a[3] = 3;
}
Gcc can vectorize both foo4_2 and foo4_3 with
add new stmt: MEM <vector(2) short int> [(short int *)vectp.5_5] = { 0, 1 };
add new stmt: MEM <vector(2) short int> [(short int *)vectp.10_5] = { 2, 3 }