diff options
Diffstat (limited to 'gcc/testsuite/gcc.dg/vect')
41 files changed, 704 insertions, 15 deletions
diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-41.c b/gcc/testsuite/gcc.dg/vect/bb-slp-41.c index 5a2bd4d..89e0bcd 100644 --- a/gcc/testsuite/gcc.dg/vect/bb-slp-41.c +++ b/gcc/testsuite/gcc.dg/vect/bb-slp-41.c @@ -59,4 +59,4 @@ int main () return 0; } -/* { dg-final { scan-tree-dump-not "vectorizing stmts using SLP" "slp1" } } */ +/* { dg-final { scan-tree-dump-not "vectorizable constructor" "slp1" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/complex/complex-operations-run.c b/gcc/testsuite/gcc.dg/vect/complex/vect-complex-operations-run.c index 2f916ab..2f916ab 100644 --- a/gcc/testsuite/gcc.dg/vect/complex/complex-operations-run.c +++ b/gcc/testsuite/gcc.dg/vect/complex/vect-complex-operations-run.c diff --git a/gcc/testsuite/gcc.dg/vect/costmodel/x86_64/costmodel-pr122573.c b/gcc/testsuite/gcc.dg/vect/costmodel/x86_64/costmodel-pr122573.c new file mode 100644 index 0000000..ca3294d --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/costmodel/x86_64/costmodel-pr122573.c @@ -0,0 +1,30 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-march=znver5" } */ + +struct S { + float m_col1[4]; + float m_col2[4]; + float m_col3[4]; + float m_col4[4]; +}; + +void apply(struct S *s, const float *in, float *out, long numPixels) +{ + for (long idx = 0; idx < numPixels; ++idx) + { + const float r = in[0]; + const float g = in[1]; + const float b = in[2]; + const float a = in[3]; + out[0] = r*s->m_col1[0] + g*s->m_col2[0] + b*s->m_col3[0] + a*s->m_col4[0]; + out[1] = r*s->m_col1[1] + g*s->m_col2[1] + b*s->m_col3[1] + a*s->m_col4[1]; + out[2] = r*s->m_col1[2] + g*s->m_col2[2] + b*s->m_col3[2] + a*s->m_col4[2]; + out[3] = r*s->m_col1[3] + g*s->m_col2[3] + b*s->m_col3[3] + a*s->m_col4[3]; + in += 4; + out += 4; + } +} + +/* Check that we do not use a masked epilog but a SSE one with VF 1 + (and possibly a AVX2 one as well). */ +/* { dg-final { scan-tree-dump "optimized: epilogue loop vectorized using 16 byte vectors and unroll factor 1" "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/pr122475.c b/gcc/testsuite/gcc.dg/vect/pr122475.c new file mode 100644 index 0000000..ed229c5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr122475.c @@ -0,0 +1,13 @@ +/* { dg-additional-options "-march=armv8-a+sve" { target aarch64*-*-* } } */ +/* Check that we don't ICE. */ +int a; +int b; +int main() { + for (char t = 0; t < 14; t += 2) + for (int u = 0; u < 242; u += 4) { + a = a < 0 ? a : 0; + b = b < 0 ? b : 0; + } +} + +/* { dg-final { scan-tree-dump-times "optimized: loop vectorized" 1 "vect" { target aarch64*-*-* } } } */ diff --git a/gcc/testsuite/gcc.dg/vect/pr122680.c b/gcc/testsuite/gcc.dg/vect/pr122680.c new file mode 100644 index 0000000..3e25a3f --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr122680.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O3" } */ +/* { dg-additional-options "-mavx2" { target avx2 } } */ + +void +foo (float *buf) +{ + for (unsigned long i = 0, j = 100; i < 100; i++, j--) + buf[i] = j; +} diff --git a/gcc/testsuite/gcc.dg/vect/pr122797.c b/gcc/testsuite/gcc.dg/vect/pr122797.c new file mode 100644 index 0000000..11819ef --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr122797.c @@ -0,0 +1,27 @@ +/* { dg-do run } */ +/* { dg-additional-options "-O3" } */ + +int src_stride = 0; +int dst_stride = 0; + +int main() { + char src[12] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; + char dst[16]; + char *s = src; + char *d = dst; + for (int i = 0; i < 2; i++) { + d[0] = s[0] + s[1] + s[2] + s[3] + s[4]; + d[1] = s[1] + s[2] + s[3] + s[4] + s[5]; + d[2] = s[2] + s[3] + s[4] + s[5] + s[6]; + d[3] = s[3] + s[4] + s[5] + s[6] + s[7]; + d[4] = s[4] + s[5] + s[6] + s[7] + s[8]; + d[5] = s[5] + s[6] + s[7] + s[8] + s[9]; + d[6] = s[6] + s[7] + s[8] + s[9] + s[10]; + d[7] = s[7] + s[8] + s[9] + s[10] + s[11]; + s += src_stride; + d += dst_stride; + } + + if (d[0] != 15) + __builtin_abort (); +} diff --git a/gcc/testsuite/gcc.dg/vect/pr122850.c b/gcc/testsuite/gcc.dg/vect/pr122850.c new file mode 100644 index 0000000..4f50aa9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr122850.c @@ -0,0 +1,13 @@ +/* { dg-do compile { target { x86_64-*-* i?86-*-* } } } */ +/* { dg-additional-options "-O3 -march=haswell -m32" } */ + +typedef int v2ll __attribute__ ((__vector_size__ (2 * sizeof (int)))); +typedef unsigned int v2ull __attribute__ ((__vector_size__ (2 * sizeof (int)))); +typedef __attribute__ ((__vector_size__ (2 * sizeof (short)))) short v2s; + +v2ll +f (v2ull e) +{ + v2s c = (v2s) e[0]; + return (v2ll) {(int) c, 0}; +} diff --git a/gcc/testsuite/gcc.dg/vect/pr122855.c b/gcc/testsuite/gcc.dg/vect/pr122855.c new file mode 100644 index 0000000..3084d20 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr122855.c @@ -0,0 +1,15 @@ +/* { dg-do compile { target { x86_64-*-* i?86-*-* } } } */ +/* { dg-additional-options "-O3 -march=haswell" } */ + +int zoom_x3_weights_0, zoom_x3_j, zoom_x3_pixel2; + +void zoom_x3(char *__restrict s, char *__restrict zoom_x3_tmp) { + int pixel0 = 0, pixel1 = 0; + for (; zoom_x3_j; zoom_x3_j--) { + pixel0 += *s++ * zoom_x3_weights_0; + pixel1 += *s++ * zoom_x3_weights_0; + zoom_x3_pixel2 += *s++ * zoom_x3_weights_0; + } + *zoom_x3_tmp++ = pixel0 < 0 ? 0 : pixel0 > 255 ? 255 : pixel0; + *zoom_x3_tmp = pixel1 < 0 ? 0 : pixel1 > 255 ? 255 : pixel1; +} diff --git a/gcc/testsuite/gcc.dg/vect/pr122969.c b/gcc/testsuite/gcc.dg/vect/pr122969.c new file mode 100644 index 0000000..47699fd --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr122969.c @@ -0,0 +1,16 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-w -O3 -fno-tree-dominator-opts -fno-code-hoisting -fno-tree-pre -fno-tree-dce" } */ + +/* { dg-final { scan-tree-dump "loop vectorized" "vect" } } */ + +int a, b; +int main() { + while (a) + for (a = 0; a != 1; a--) + if (b) + break; + return 0; +} + diff --git a/gcc/testsuite/gcc.dg/vect/pr123038.c b/gcc/testsuite/gcc.dg/vect/pr123038.c new file mode 100644 index 0000000..bca831f --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr123038.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ + +unsigned char f(int b) +{ + for (int a = 0; a < 10; a += 1) + b = __builtin_ffs(b); + return b; +} diff --git a/gcc/testsuite/gcc.dg/vect/slp-58.c b/gcc/testsuite/gcc.dg/vect/slp-58.c new file mode 100644 index 0000000..e03cfa3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/slp-58.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ + +struct S { + float m_col1[4]; + float m_col2[4]; + float m_col3[4]; + float m_col4[4]; +}; + +void apply(struct S *s, const float *in, float *out, long numPixels) +{ + for (long idx = 0; idx < numPixels; ++idx) + { + const float r = in[0]; + const float g = in[1]; + const float b = in[2]; + const float a = in[3]; + out[0] = r*s->m_col1[0] + g*s->m_col2[0] + b*s->m_col3[0] + a*s->m_col4[0]; + out[1] = r*s->m_col1[1] + g*s->m_col2[1] + b*s->m_col3[1] + a*s->m_col4[1]; + out[2] = r*s->m_col1[2] + g*s->m_col2[2] + b*s->m_col3[2] + a*s->m_col4[2]; + out[3] = r*s->m_col1[3] + g*s->m_col2[3] + b*s->m_col3[3] + a*s->m_col4[3]; + in += 4; + out += 4; + } +} + +/* { dg-final { scan-tree-dump "vectorization factor = 1" "vect" { target { ! vect_load_lanes } } } } */ diff --git a/gcc/testsuite/gcc.dg/vect/slp-9.c b/gcc/testsuite/gcc.dg/vect/slp-9.c index 4fb6953..8869764 100644 --- a/gcc/testsuite/gcc.dg/vect/slp-9.c +++ b/gcc/testsuite/gcc.dg/vect/slp-9.c @@ -1,5 +1,4 @@ /* { dg-require-effective-target vect_int } */ -/* { dg-additional-options "-fno-early-inlining" } */ #include <stdarg.h> #include "tree-vect.h" @@ -11,7 +10,7 @@ short Y[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); int result[N]; /* short->int widening-mult */ -int +int __attribute__((noipa)) foo1(int len) { int i; diff --git a/gcc/testsuite/gcc.dg/vect/slp-reduc-13.c b/gcc/testsuite/gcc.dg/vect/slp-reduc-13.c new file mode 100644 index 0000000..00e91fc --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/slp-reduc-13.c @@ -0,0 +1,66 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fgimple" } */ + +int q[2]; + +void __GIMPLE (ssa,guessed_local(16535624),startwith("loop")) +foo (int * r) +{ + int i; + int sum2; + int sum1; + int _1; + long unsigned int _2; + long unsigned int _3; + int * _4; + int _24; + __SIZETYPE__ _6; + __SIZETYPE__ _7; + int * _8; + int _9; + int _13; + unsigned int _30; + unsigned int _31; + + __BB(2,guessed_local(16535624)): + goto __BB3(precise(134217728)); + + __BB(3,loop_header(1),guessed_local(1057206200)): + sum1_5 = __PHI (__BB5: sum1_18, __BB2: 0); + sum2_26 = __PHI (__BB5: sum2_19, __BB2: 0); + i_28 = __PHI (__BB5: i_20, __BB2: 0); + _31 = __PHI (__BB5: _30, __BB2: 64u); + _1 = i_28 * 2; + _2 = (long unsigned int) _1; + _3 = _2 * 4ul; + _4 = r_17(D) + _3; + _24 = __MEM <int> (_4); + /* Deliberately have swapped operands here */ + sum1_18 = sum1_5 + _24; + _13 = _1 + 1; + _6 = (__SIZETYPE__) _13; + _7 = _6 * 4ul; + _8 = r_17(D) + _7; + _9 = __MEM <int> (_8); + /* versus here. */ + sum2_19 = _9 + sum2_26; + i_20 = i_28 + 1; + _30 = _31 - 1u; + if (_30 != 0u) + goto __BB5(guessed(132118446)); + else + goto __BB4(guessed(2099282)); + + __BB(5,guessed_local(1040670576)): + goto __BB3(precise(134217728)); + + __BB(4,guessed_local(16535624)): + sum1_33 = __PHI (__BB3: sum1_18); + sum2_32 = __PHI (__BB3: sum2_19); + q[0] = sum1_33; + q[1] = sum2_32; + return; +} + +/* { dg-final { scan-tree-dump "SLP discovery of size 2 reduction group succeeded" "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/slp-reduc-14.c b/gcc/testsuite/gcc.dg/vect/slp-reduc-14.c new file mode 100644 index 0000000..7966d23 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/slp-reduc-14.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ + +void foo (int * __restrict sums, int *a, int *b, int n) +{ + for (int i = 0; i < n; ++i) + { + sums[0] = sums[0] + a[2*i]; + sums[1] = sums[1] + a[2*i+1]; + sums[2] = sums[2] + b[2*i]; + sums[3] = sums[3] + b[2*i+1]; + } +} + +/* { dg-final { scan-tree-dump-times "SLP discovery of size 2 reduction group" 2 "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/slp-widen-mult-half.c b/gcc/testsuite/gcc.dg/vect/slp-widen-mult-half.c index b69ade3..72811eb 100644 --- a/gcc/testsuite/gcc.dg/vect/slp-widen-mult-half.c +++ b/gcc/testsuite/gcc.dg/vect/slp-widen-mult-half.c @@ -1,7 +1,6 @@ /* Disabling epilogues until we find a better way to deal with scans. */ /* { dg-additional-options "--param vect-epilogues-nomask=0" } */ /* { dg-require-effective-target vect_int } */ -/* { dg-additional-options "-mlasx" { target loongarch*-*-* } } */ #include "tree-vect.h" diff --git a/gcc/testsuite/gcc.dg/vect/tree-vect.h b/gcc/testsuite/gcc.dg/vect/tree-vect.h index 1e4b56e..37908c9 100644 --- a/gcc/testsuite/gcc.dg/vect/tree-vect.h +++ b/gcc/testsuite/gcc.dg/vect/tree-vect.h @@ -76,6 +76,8 @@ check_vect (void) } #elif defined(__mips_msa) asm volatile ("or.v $w0,$w0,$w0"); +#elif defined(__loongarch__) + asm volatile ("vor.v\t$vr0,$vr0,$vr0"); #endif signal (SIGILL, SIG_DFL); } diff --git a/gcc/testsuite/gcc.dg/vect/tsvc/vect-tsvc-s293.c b/gcc/testsuite/gcc.dg/vect/tsvc/vect-tsvc-s293.c index 3213948..34f6af0 100644 --- a/gcc/testsuite/gcc.dg/vect/tsvc/vect-tsvc-s293.c +++ b/gcc/testsuite/gcc.dg/vect/tsvc/vect-tsvc-s293.c @@ -36,4 +36,4 @@ int main (int argc, char **argv) return 0; } -/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect"} } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-bool-3.c b/gcc/testsuite/gcc.dg/vect/vect-bool-3.c new file mode 100644 index 0000000..671f602 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-bool-3.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_unpack } */ + +int count_true(const bool *values, int len) +{ + int count = 0; + for (int i = 0; i < len; i++) + count += values[i]; + return count; +} + +/* { dg-final { scan-tree-dump "optimized: loop vectorized" "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-early-break_139.c b/gcc/testsuite/gcc.dg/vect/vect-early-break_139.c new file mode 100644 index 0000000..9599493 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-early-break_139.c @@ -0,0 +1,37 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-require-effective-target vect_early_break_hw } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ + +#include "tree-vect.h" + +__attribute__((noipa)) +unsigned loop9(unsigned char *a, unsigned n, unsigned c) +{ + for (unsigned j = 0;;) + { + if (c <= j) + __builtin_abort(); + + unsigned char *slot = (unsigned char *)a + j; + + *slot = (char)j; + + unsigned d = j + 1; + if (d < n) + j = d; + else + return d; + } +} + +int main () +{ + check_vect (); + + unsigned char buff[16] = {0}; + unsigned res = loop9 (buff, 16, 20); + if (res != 16) + __builtin_abort (); +} diff --git a/gcc/testsuite/gcc.dg/vect/vect-early-break_140-pr122868_1.c b/gcc/testsuite/gcc.dg/vect/vect-early-break_140-pr122868_1.c new file mode 100644 index 0000000..80264bd --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-early-break_140-pr122868_1.c @@ -0,0 +1,39 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-require-effective-target vect_sizes_16B_8B } */ +/* { dg-require-effective-target vect_early_break_hw } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ + +#include "tree-vect.h" + +__attribute__ ((noipa)) +int f (int a[12], int b[12], int n) +{ +#ifdef __arm__ + a = __builtin_assume_aligned (a, 8); + b = __builtin_assume_aligned (b, 8); +#else + a = __builtin_assume_aligned (a, 16); + b = __builtin_assume_aligned (b, 16); +#endif + for (int i = 0; i < n; i++) + { + if (b[i] == 0) + return 0; + if (a[0] > b[i]) + return 1; + } + return 2; +} + +int main () +{ + check_vect (); + + int *a = 0; + int b[12] = {0}; + return f (a, b, 10); +} + +/* { dg-final { scan-tree-dump "not hoisting invariant load due to early break" "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-early-break_140-pr122868_2.c b/gcc/testsuite/gcc.dg/vect/vect-early-break_140-pr122868_2.c new file mode 100644 index 0000000..90222fc --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-early-break_140-pr122868_2.c @@ -0,0 +1,31 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-require-effective-target vect_early_break_hw } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ + +#include "tree-vect.h" + +__attribute__ ((noipa)) +int f (int a[12], int b[12], int n) +{ + for (int i = 0; i < n; i++) + { + if (b[i] == 0) + return 0; + if (a[0] > b[i]) + return 1; + } + return 2; +} + +int main () +{ + check_vect (); + + int *a = 0; + int b[12] = {0}; + return f (a, b, 10); +} + +/* { dg-final { scan-tree-dump-times "not hoisting invariant load due to early break" 0 "vect" { xfail *-*-* } } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-early-break_140-pr122868_3.c b/gcc/testsuite/gcc.dg/vect/vect-early-break_140-pr122868_3.c new file mode 100644 index 0000000..670804f --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-early-break_140-pr122868_3.c @@ -0,0 +1,39 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-require-effective-target vect_sizes_16B_8B } */ +/* { dg-require-effective-target vect_early_break_hw } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ + +#include "tree-vect.h" + +__attribute__ ((noipa)) +int f (int a[12], int b[12], int n) +{ +#ifdef __arm__ + a = __builtin_assume_aligned (a, 8); + b = __builtin_assume_aligned (b, 8); +#else + a = __builtin_assume_aligned (a, 16); + b = __builtin_assume_aligned (b, 16); +#endif + for (int i = 0; i < n; i++) + { + if (a[0] > b[i]) + return 0; + if (b[i] == 0) + return 1; + } + return 2; +} + +int main () +{ + check_vect (); + + int a[12] = {1}; + int b[12] = {0}; + return f (a, b, 10); +} + +/* { dg-final { scan-tree-dump-times "not hoisting invariant load due to early break" 0 "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-early-break_140-pr122868_4.c b/gcc/testsuite/gcc.dg/vect/vect-early-break_140-pr122868_4.c new file mode 100644 index 0000000..de2aff2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-early-break_140-pr122868_4.c @@ -0,0 +1,31 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-require-effective-target vect_early_break_hw } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ + +#include "tree-vect.h" + +__attribute__ ((noipa)) +int f (int a[12], int b[12], int n) +{ + for (int i = 0; i < n; i++) + { + if (a[0] > b[i]) + return 0; + if (b[i] == 0) + return 0; + } + return 2; +} + +int main () +{ + check_vect (); + + int a[12] = {1}; + int b[12] = {0}; + return f (a, b, 10); +} + +/* { dg-final { scan-tree-dump-times "not hoisting invariant load due to early break" 0 "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-early-break_39.c b/gcc/testsuite/gcc.dg/vect/vect-early-break_39.c index b3f40b8..bc862ad 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-early-break_39.c +++ b/gcc/testsuite/gcc.dg/vect/vect-early-break_39.c @@ -23,5 +23,6 @@ unsigned test4(unsigned x, unsigned n) return ret; } -/* cannot safely vectorize this due due to the group misalignment. */ -/* { dg-final { scan-tree-dump-times "vectorized 1 loops in function" 0 "vect" } } */ +/* AArch64 will scalarize the load and is able to vectorize it. */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops in function" 1 "vect" { target aarch64*-*-* } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops in function" 0 "vect" { target { ! aarch64*-*-* } } } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-licm-hoist-1.c b/gcc/testsuite/gcc.dg/vect/vect-licm-hoist-1.c new file mode 100644 index 0000000..2e850eb --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-licm-hoist-1.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-additional-options "-fdump-tree-lim2-details -fdump-tree-vect-details" } */ + +/* Test vectorization of "self write" pattern: a[i] = a[0]. + LICM should hoist a[0] by recognizing that even when i==0 causes + aliasing, the stored value equals the loaded value (via SSA). */ + +#define N 32000 + +float a[N]; + +/* Should vectorize. */ + +void +test_safe_hoist (void) +{ + for (int i = 0; i < N; i++) + a[i] = a[0]; +} + +/* { dg-final { scan-tree-dump "loop vectorized" "vect" } } */ +/* { dg-final { scan-tree-dump "independent \\(self write\\)" "lim2" } } */ + diff --git a/gcc/testsuite/gcc.dg/vect/vect-licm-hoist-2.c b/gcc/testsuite/gcc.dg/vect/vect-licm-hoist-2.c new file mode 100644 index 0000000..c42dc3f --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-licm-hoist-2.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-additional-options "-fdump-tree-lim2-details -fdump-tree-vect-details" } */ + +/* Negative test: ensure we don't incorrectly hoist when + a store invalidates the loaded value. */ + +#define N 32000 + +float a[N]; + +/* Should NOT hoist: a[0] = 5.0f breaks the SSA dependency. */ + +void +test_unsafe_hoist (void) +{ + for (int i = 0; i < N; i++) + { + float x = a[0]; + a[i] = x; + a[0] = 5.0f; + } +} + +/* { dg-final { scan-tree-dump-not "independent \\(constant-indexed load" "lim2" } } */ + diff --git a/gcc/testsuite/gcc.dg/vect/vect-pr122844.c b/gcc/testsuite/gcc.dg/vect/vect-pr122844.c new file mode 100644 index 0000000..52da3ec --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-pr122844.c @@ -0,0 +1,34 @@ +#include "tree-vect.h" + +short c = 2; +short l = 6; +unsigned char m; +int k; +int a = -1; +unsigned long long t[2][2]; + +static void b( short c, int k, short l, unsigned m) +{ + for( signed x=0; x<2; x++) + for( int ab=0; ab<k+2; ab++) + a = ({ + int ac = a; + int ad = ({ int ac = l ? m : t[x][0]; + unsigned long long ad = c ? m : t[x][x]; + ac < ad ? ac : ad; }); + + ac < ad ? ac : ad; + }); +} + +int main() +{ + check_vect (); + + long long ag; + b(c,k,l,m); + ag = a; + if (ag != -1) + abort (); +} + diff --git a/gcc/testsuite/gcc.dg/vect/vect-pr123002.c b/gcc/testsuite/gcc.dg/vect/vect-pr123002.c new file mode 100644 index 0000000..3b45c48 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-pr123002.c @@ -0,0 +1,39 @@ +/* { dg-additional-options "-mavx2" { target avx2 } } */ + +#include "tree-vect.h" + +unsigned int enc_table_32[8][3] = { + {513735U, 77223048U, 437087610U }, + {0U, 78508U, 646269101U }, + {0U, 0U, 11997U, }, + {0U, 0U, 0U, }, + {0U, 0U, 0U, }, + {0U, 0U, 0U, }, + {0U, 0U, 0U, }, + {0U, 0U, 0U, }}; + +int __attribute__((noipa)) foo() +{ + unsigned long intermediate[3] = {0}; + + for (unsigned long i = 0UL; i < 8; i++) { + intermediate[0] += 2 * (unsigned long)(enc_table_32)[i][0]; + intermediate[1] += 2 * (unsigned long)(enc_table_32)[i][1]; + intermediate[2] += 2 * (unsigned long)(enc_table_32)[i][2]; + } + + if (intermediate[0] == 0xfad8e && + intermediate[1] == 0x9370e68 && intermediate[2] == 0x8125ca08) { + return 0; + } else { + return 1; + } +} + +int main() +{ + check_vect (); + if (foo ()) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/vect/vect-reduc-cond-add-1.c b/gcc/testsuite/gcc.dg/vect/vect-reduc-cond-add-1.c new file mode 100644 index 0000000..1e64df7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-reduc-cond-add-1.c @@ -0,0 +1,50 @@ +#include "tree-vect.h" + +char mask[128]; + +double __attribute__((noipa)) +foo (double *a, int n) +{ + double sum = 0.0; + for (int i = 0; i < n; ++i) + { + double val; + if (mask[i]) + val = a[i]; + else + val = -0.0; + sum = sum + val; + } + return sum; +} + +double a[128]; + +int main() +{ + check_vect (); + +#pragma GCC novector + for (int i = 0; i < 128; ++i) + { + a[i] = (i * 7) % 15; + mask[i] = (i + 1) & 4; + } + + double sum = foo (a, 87); + double sum2 = 0.0; +#pragma GCC novector + for (int i = 0; i < 87; ++i) + { + double val; + if (mask[i]) + val = a[i]; + else + val = -0.0; + sum2 = sum2 + val; + } + + if (sum != sum2) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/vect/vect-simd-clone-22.c b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-22.c new file mode 100644 index 0000000..732d2328 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-22.c @@ -0,0 +1,46 @@ +/* { dg-require-effective-target vect_simd_clones } */ +/* { dg-additional-options "-fopenmp-simd --param vect-partial-vector-usage=2 -w" } */ +/* { dg-additional-options "-mavx512f" { target avx512f_runtime } } */ +/* { dg-add-options ieee } */ +/* { dg-require-effective-target fenv_exceptions } */ +/* { dg-additional-sources vect-simd-clone-22a.c linkonly } */ + +#include <fenv.h> +#include "tree-vect.h" + +#pragma omp declare simd simdlen(16) inbranch +float __attribute__((const)) baz (float x, float y); + +float a[1024]; +int c[1024]; + +void __attribute__((noipa)) +foo (int n, float * __restrict b) +{ + for (int i = 0; i < n; ++i) + { + float aa = a[i]; + float bb = b[i]; + if (c[i] == 0) + aa = baz (aa, bb); + a[i] = aa; + } +} + +float b[1024]; + +int main() +{ + check_vect (); + +#pragma GCC novector + for (int i = 0; i < 1020; ++i) + a[i] = b[i] = 2; + foo (1020, b); + if (fetestexcept (FE_DIVBYZERO) || fetestexcept (FE_INVALID)) + abort (); +#pragma GCC novector + for (int i = 0; i < 1020; ++i) + if (a[i] != 1) + abort (); +} diff --git a/gcc/testsuite/gcc.dg/vect/vect-simd-clone-22a.c b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-22a.c new file mode 100644 index 0000000..88bda07 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-22a.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ + +#pragma omp declare simd simdlen(16) inbranch +float baz (float x, float y) +{ + return x / y; +} diff --git a/gcc/testsuite/gcc.dg/vect/vect-simd-clone-23.c b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-23.c new file mode 100644 index 0000000..b673ee0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-23.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_simd_clones } */ +/* { dg-additional-options "-fopenmp-simd -w" } */ +/* { dg-additional-options "-mavx512bw" { target avx512bw } } */ + +#pragma omp declare simd simdlen(32) inbranch +int __attribute__((const)) baz (int x); + +short a[1024]; + +void __attribute__((noipa)) +foo (int n, int * __restrict b) +{ + for (int i = 0; i < n; ++i) + if (a[i]) + b[i] = baz (b[i]); +} diff --git a/gcc/testsuite/gcc.dg/vect/vect-simd-clone-24.c b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-24.c new file mode 100644 index 0000000..5281dfa --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-24.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */ +/* { dg-require-effective-target vect_simd_clones } */ +/* { dg-additional-options "-fopenmp-simd --param vect-partial-vector-usage=1 -fdump-tree-dce6 -w" } */ +/* { dg-additional-options "-mavx512f -mprefer-vector-width=512" { target avx512f } } */ + +#pragma omp declare simd simdlen(16) +int __attribute__((const)) baz (int x); + +int a[1024]; + +void foo (int n, int * __restrict b) +{ + for (int i = 0; i < n; ++i) + if (baz (a[i])) + b[i] = baz (b[i]); +} + +/* One notinbranch SIMD call, one inbranch in the main vector loop and two + inbranch in the masked epilog. */ +/* { dg-final { scan-tree-dump-times "simdclone\.\[0-9\] \\\(\[^,\]\+\\\)" 1 "dce6" { target avx512f } } } */ +/* { dg-final { scan-tree-dump-times "simdclone\.\[0-9\] \\\(\[^,\]\+,\[^,\]\+\\\)" 3 "dce6" { target avx512f } } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-widen-mult-const-s16.c b/gcc/testsuite/gcc.dg/vect/vect-widen-mult-const-s16.c index 53c9b84..dfbb217 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-widen-mult-const-s16.c +++ b/gcc/testsuite/gcc.dg/vect/vect-widen-mult-const-s16.c @@ -2,7 +2,6 @@ /* { dg-additional-options "--param vect-epilogues-nomask=0" } */ /* { dg-require-effective-target vect_int } */ /* { dg-additional-options "-fno-ipa-icf" } */ -/* { dg-additional-options "-mlasx" { target loongarch*-*-*} } */ #include "tree-vect.h" diff --git a/gcc/testsuite/gcc.dg/vect/vect-widen-mult-const-u16.c b/gcc/testsuite/gcc.dg/vect/vect-widen-mult-const-u16.c index e9db828..c2ad58f 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-widen-mult-const-u16.c +++ b/gcc/testsuite/gcc.dg/vect/vect-widen-mult-const-u16.c @@ -2,7 +2,6 @@ /* { dg-additional-options "--param vect-epilogues-nomask=0" } */ /* { dg-require-effective-target vect_int } */ /* { dg-additional-options "-fno-ipa-icf" } */ -/* { dg-additional-options "-mlasx" { target loongarch*-*-*} } */ #include "tree-vect.h" diff --git a/gcc/testsuite/gcc.dg/vect/vect-widen-mult-half-u8.c b/gcc/testsuite/gcc.dg/vect/vect-widen-mult-half-u8.c index 607f317..bfdcbaa 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-widen-mult-half-u8.c +++ b/gcc/testsuite/gcc.dg/vect/vect-widen-mult-half-u8.c @@ -2,7 +2,6 @@ /* { dg-additional-options "--param vect-epilogues-nomask=0" } */ /* { dg-require-effective-target vect_int } */ /* { dg-additional-options "-fno-ipa-icf" } */ -/* { dg-additional-options "-mlasx" { target loongarch*-*-*} } */ #include "tree-vect.h" diff --git a/gcc/testsuite/gcc.dg/vect/vect-widen-mult-half.c b/gcc/testsuite/gcc.dg/vect/vect-widen-mult-half.c index cd13d82..e46b0cc 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-widen-mult-half.c +++ b/gcc/testsuite/gcc.dg/vect/vect-widen-mult-half.c @@ -1,7 +1,6 @@ /* Disabling epilogues until we find a better way to deal with scans. */ /* { dg-additional-options "--param vect-epilogues-nomask=0" } */ /* { dg-require-effective-target vect_int } */ -/* { dg-additional-options "-mlasx" { target loongarch*-*-*} } */ #include "tree-vect.h" diff --git a/gcc/testsuite/gcc.dg/vect/vect-widen-mult-u16.c b/gcc/testsuite/gcc.dg/vect/vect-widen-mult-u16.c index 258d253..14411ef 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-widen-mult-u16.c +++ b/gcc/testsuite/gcc.dg/vect/vect-widen-mult-u16.c @@ -1,7 +1,6 @@ /* Disabling epilogues until we find a better way to deal with scans. */ /* { dg-additional-options "--param vect-epilogues-nomask=0" } */ /* { dg-require-effective-target vect_int } */ -/* { dg-additional-options "-mlasx" { target loongarch*-*-*} } */ #include <stdarg.h> #include "tree-vect.h" diff --git a/gcc/testsuite/gcc.dg/vect/vect-widen-mult-u8-s16-s32.c b/gcc/testsuite/gcc.dg/vect/vect-widen-mult-u8-s16-s32.c index 3baafca..f40def5 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-widen-mult-u8-s16-s32.c +++ b/gcc/testsuite/gcc.dg/vect/vect-widen-mult-u8-s16-s32.c @@ -1,7 +1,6 @@ /* Disabling epilogues until we find a better way to deal with scans. */ /* { dg-additional-options "--param vect-epilogues-nomask=0" } */ /* { dg-require-effective-target vect_int } */ -/* { dg-additional-options "-mlasx" { target loongarch*-*-*} } */ #include <stdarg.h> #include "tree-vect.h" diff --git a/gcc/testsuite/gcc.dg/vect/vect-widen-mult-u8-u32.c b/gcc/testsuite/gcc.dg/vect/vect-widen-mult-u8-u32.c index bcfbe19..6386639 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-widen-mult-u8-u32.c +++ b/gcc/testsuite/gcc.dg/vect/vect-widen-mult-u8-u32.c @@ -1,6 +1,5 @@ /* { dg-additional-options "--param vect-epilogues-nomask=0" } */ /* { dg-require-effective-target vect_int } */ -/* { dg-additional-options "-mlasx" { target loongarch*-*-* } } */ #include <stdarg.h> #include "tree-vect.h" diff --git a/gcc/testsuite/gcc.dg/vect/vect-widen-mult-u8.c b/gcc/testsuite/gcc.dg/vect/vect-widen-mult-u8.c index e3bf13b..78ad74b 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-widen-mult-u8.c +++ b/gcc/testsuite/gcc.dg/vect/vect-widen-mult-u8.c @@ -1,6 +1,5 @@ /* { dg-additional-options "--param vect-epilogues-nomask=0" } */ /* { dg-require-effective-target vect_int } */ -/* { dg-additional-options "-mlasx" { target loongarch*-*-*} } */ #include <stdarg.h> #include "tree-vect.h" |
