]> git.ipfire.org Git - people/ms/gcc.git/blame - gcc/testsuite/gcc.dg/vect/vect-simd-clone-18.c
testsuite: Remove obsolete comments [PR108898]
[people/ms/gcc.git] / gcc / testsuite / gcc.dg / vect / vect-simd-clone-18.c
CommitLineData
3da77f21 1/* { dg-require-effective-target vect_simd_clones } */
b49aedf6 2/* { dg-additional-options "-fopenmp-simd --param vect-epilogues-nomask=0" } */
3da77f21
AS
3/* { dg-additional-options "-mavx" { target avx_runtime } } */
4
5/* Test that simd inbranch clones work correctly. */
6
7#ifndef TYPE
8#define TYPE int
9#endif
10
11/* A simple function that will be cloned. */
12#pragma omp declare simd uniform(b)
13TYPE __attribute__((noinline))
14foo (TYPE b, TYPE a)
15{
16 return a + b;
17}
18
19/* Check that "inbranch" clones are called correctly. */
20
21void __attribute__((noipa))
22masked (TYPE * __restrict a, TYPE * __restrict b, int size)
23{
24 #pragma omp simd
25 for (int i = 0; i < size; i++)
26 b[i] = a[i]<1 ? foo(1, a[i]) : a[i];
27}
28
29/* Check that "inbranch" works when there might be unrolling. */
30
31void __attribute__((noipa))
32masked_fixed (TYPE * __restrict a, TYPE * __restrict b)
33{
34 #pragma omp simd
35 for (int i = 0; i < 128; i++)
36 b[i] = a[i]<1 ? foo(1, a[i]) : a[i];
37}
38
39/* Validate the outputs. */
40
41void
42check_masked (TYPE *b, int size)
43{
44 for (int i = 0; i < size; i++)
45 if (((TYPE)i < 1 && b[i] != (TYPE)(i + 1))
46 || ((TYPE)i >= 1 && b[i] != (TYPE)i))
47 {
48 __builtin_printf ("error at %d\n", i);
49 __builtin_exit (1);
50 }
51}
52
53int
54main ()
55{
56 TYPE a[1024];
57 TYPE b[1024];
58
59 for (int i = 0; i < 1024; i++)
60 a[i] = i;
61
62 masked_fixed (a, b);
63 check_masked (b, 128);
64
65 /* Test various sizes to cover machines with different vectorization
66 factors. */
67 for (int size = 8; size <= 1024; size *= 2)
68 {
69 masked (a, b, size);
70 check_masked (b, size);
71 }
72
73 /* Test sizes that might exercise the partial vector code-path. */
74 for (int size = 8; size <= 1024; size *= 2)
75 {
76 masked (a, b, size-4);
77 check_masked (b, size-4);
78 }
79
80 return 0;
81}
82
49a8bce4 83/* Ensure the the in-branch simd clones are used on targets that support them. */
b49aedf6 84/* { dg-final { scan-tree-dump-times {[\n\r] [^\n]* = foo\.simdclone} 2 "vect" } } */
3da77f21
AS
85
86/* The LTO test produces two dump files and we scan the wrong one. */
87/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */