As noted in the PR, we were no longer using ST3 for the testcase and instead stored each lane individually. This is because we'd split the store group during SLP and couldn't recover when SLP failed. However, we can also get better code with ST3 and ST4 even if SLP would have succeeded, such as for vect-complex-5.c. I'm not sure exactly where the cut-off point is, but it seems reasonable to allow the split if either of the new groups would operate on full vectors *within* rather than across scalar loop iterations. E.g. on a Cortex-A57, pr99873_3.c performs better using ST4 while pr99873_2.c performs better with SLP. Another factor is that SLP can handle smaller iteration counts than IFN_STORE_LANES can, but we don't have the infrastructure to choose reliably based on that. gcc/ PR tree-optimization/99873 * tree-vect-slp.c (vect_slp_prefer_store_lanes_p): New function. (vect_build_slp_instance): Don't split store groups that could use IFN_STORE_LANES. gcc/testsuite/ * gcc.dg/vect/slp-21.c: Only expect 2 of the loops to use SLP if IFN_STORE_LANES is available. * gcc.dg/vect/vect-complex-5.c: Expect no loops to use SLP if IFN_STORE_LANES is available. * gcc.target/aarch64/pr99873_1.c: New test. * gcc.target/aarch64/pr99873_2.c: Likewise. * gcc.target/aarch64/pr99873_3.c: Likewise. * gcc.target/aarch64/sve/pr99873_1.c: Likewise. * gcc.target/aarch64/sve/pr99873_2.c: Likewise. * gcc.target/aarch64/sve/pr99873_3.c: Likewise.
217 lines
4.5 KiB
C
217 lines
4.5 KiB
C
/* { dg-require-effective-target vect_int } */
|
|
|
|
#include <stdarg.h>
|
|
#include "tree-vect.h"
|
|
|
|
#define N 128
|
|
|
|
int
|
|
main1 ()
|
|
{
|
|
unsigned short i;
|
|
unsigned short out[N*8], out2[N*8], b0, b1, b2, b3, b4, a0, a1, a2, a3, b5;
|
|
unsigned short in[N*8];
|
|
|
|
for (i = 0; i < N*8; i++)
|
|
{
|
|
in[i] = i;
|
|
}
|
|
|
|
/* Different operations in both cases - vectorization with interleaving. */
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
a0 = in[i*4];
|
|
a1 = in[i*4 + 1];
|
|
a2 = in[i*4 + 2];
|
|
a3 = in[i*4 + 3];
|
|
|
|
b0 = a0 * 8;
|
|
b1 = a1 + 7;
|
|
b2 = a2 + 6;
|
|
b3 = a3 * 5;
|
|
|
|
b4 = a2 + 4;
|
|
b5 = a3 + 3;
|
|
|
|
out[i*4] = b0;
|
|
out[i*4 + 1] = b1;
|
|
out[i*4 + 2] = b2;
|
|
out[i*4 + 3] = b3;
|
|
|
|
out2[i*4] = b0;
|
|
out2[i*4 + 1] = b1;
|
|
out2[i*4 + 2] = b4;
|
|
out2[i*4 + 3] = b5;
|
|
}
|
|
|
|
/* check results: */
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
a0 = in[i*4];
|
|
a1 = in[i*4 + 1];
|
|
a2 = in[i*4 + 2];
|
|
a3 = in[i*4 + 3];
|
|
|
|
b0 = a0 * 8;
|
|
b1 = a1 + 7;
|
|
b2 = a2 + 6;
|
|
b3 = a3 * 5;
|
|
|
|
b4 = a2 + 4;
|
|
b5 = a3 + 3;
|
|
|
|
if (out[i*4] != b0
|
|
|| out[i*4 + 1] != b1
|
|
|| out[i*4 + 2] != b2
|
|
|| out[i*4 + 3] != b3)
|
|
abort ();
|
|
|
|
if (out2[i*4] != b0
|
|
|| out2[i*4 + 1] != b1
|
|
|| out2[i*4 + 2] != b4
|
|
|| out2[i*4 + 3] != b5)
|
|
abort ();
|
|
}
|
|
|
|
/* Different operations in the first case - vectorization with interleaving. */
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
a0 = in[i*4];
|
|
a1 = in[i*4 + 1];
|
|
a2 = in[i*4 + 2];
|
|
a3 = in[i*4 + 3];
|
|
|
|
b0 = a0 + 8;
|
|
b1 = a1 + 7;
|
|
b2 = a2 + 6;
|
|
b3 = a3 * 5;
|
|
|
|
b4 = a2 + 4;
|
|
b5 = a3 + 3;
|
|
|
|
out[i*4] = b0;
|
|
out[i*4 + 1] = b1;
|
|
out[i*4 + 2] = b2;
|
|
out[i*4 + 3] = b3;
|
|
|
|
out2[i*4] = b0;
|
|
out2[i*4 + 1] = b1;
|
|
out2[i*4 + 2] = b4;
|
|
out2[i*4 + 3] = b5;
|
|
}
|
|
|
|
/* check results: */
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
a0 = in[i*4];
|
|
a1 = in[i*4 + 1];
|
|
a2 = in[i*4 + 2];
|
|
a3 = in[i*4 + 3];
|
|
|
|
b0 = a0 + 8;
|
|
b1 = a1 + 7;
|
|
b2 = a2 + 6;
|
|
b3 = a3 * 5;
|
|
|
|
b4 = a2 + 4;
|
|
b5 = a3 + 3;
|
|
|
|
if (out[i*4] != b0
|
|
|| out[i*4 + 1] != b1
|
|
|| out[i*4 + 2] != b2
|
|
|| out[i*4 + 3] != b3)
|
|
abort ();
|
|
|
|
if (out2[i*4] != b0
|
|
|| out2[i*4 + 1] != b1
|
|
|| out2[i*4 + 2] != b4
|
|
|| out2[i*4 + 3] != b5)
|
|
abort ();
|
|
}
|
|
|
|
|
|
/* Different operations in the second case - vectorization with interleaving. */
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
a0 = in[i*4];
|
|
a1 = in[i*4 + 1];
|
|
a2 = in[i*4 + 2];
|
|
a3 = in[i*4 + 3];
|
|
|
|
b0 = a0 + 8;
|
|
b1 = a1 + 7;
|
|
b2 = a2 + 6;
|
|
b3 = a3 + 5;
|
|
|
|
b4 = a2 * 4;
|
|
b5 = a3 + 3;
|
|
|
|
out[i*4] = b0;
|
|
out[i*4 + 1] = b1;
|
|
out[i*4 + 2] = b2;
|
|
out[i*4 + 3] = b3;
|
|
|
|
out2[i*4] = b0;
|
|
out2[i*4 + 1] = b1;
|
|
out2[i*4 + 2] = b4;
|
|
out2[i*4 + 3] = b5;
|
|
}
|
|
|
|
/* check results: */
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
a0 = in[i*4];
|
|
a1 = in[i*4 + 1];
|
|
a2 = in[i*4 + 2];
|
|
a3 = in[i*4 + 3];
|
|
|
|
b0 = a0 + 8;
|
|
b1 = a1 + 7;
|
|
b2 = a2 + 6;
|
|
b3 = a3 + 5;
|
|
|
|
b4 = a2 * 4;
|
|
b5 = a3 + 3;
|
|
|
|
if (out[i*4] != b0
|
|
|| out[i*4 + 1] != b1
|
|
|| out[i*4 + 2] != b2
|
|
|| out[i*4 + 3] != b3)
|
|
abort ();
|
|
|
|
if (out2[i*4] != b0
|
|
|| out2[i*4 + 1] != b1
|
|
|| out2[i*4 + 2] != b4
|
|
|| out2[i*4 + 3] != b5)
|
|
abort ();
|
|
}
|
|
|
|
|
|
return 0;
|
|
}
|
|
|
|
int main (void)
|
|
{
|
|
check_vect ();
|
|
|
|
main1 ();
|
|
|
|
return 0;
|
|
}
|
|
|
|
/* { dg-final { scan-tree-dump-times "vectorized 4 loops" 1 "vect" { target { vect_strided4 || vect_extract_even_odd } } } } */
|
|
/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { ! { vect_strided4 || vect_extract_even_odd } } } } } */
|
|
/* Some targets can vectorize the second of the three main loops using
|
|
hybrid SLP. For 128-bit vectors, the required 4->3 permutations are:
|
|
|
|
{ 0, 1, 2, 4, 5, 6, 8, 9 }
|
|
{ 2, 4, 5, 6, 8, 9, 10, 12 }
|
|
{ 5, 6, 8, 9, 10, 12, 13, 14 }
|
|
|
|
Not all vect_perm targets support that, and it's a bit too specific to have
|
|
its own effective-target selector, so we just test targets directly. */
|
|
/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 4 "vect" { target powerpc64*-*-* } } } */
|
|
/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" { target { vect_strided4 && { ! powerpc64*-*-* } } } } } */
|
|
/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0 "vect" { target { ! { vect_strided4 } } } } } */
|
|
|