aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.dg/vect/vect-simd-clone-6.c
blob: 26995da86e3ece87bfe437809d8196dfe842a593 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/* { dg-require-effective-target vect_simd_clones } */
/* { dg-additional-options "-fopenmp-simd" } */
/* { dg-additional-options "-mavx" { target avx_runtime } } */

#include "tree-vect.h"

#ifndef N
#define N 1024
#endif

int a[N];
long long int b[N];
short c[N];

#pragma omp declare simd
#pragma omp declare simd uniform(b) linear(c:3)
__attribute__((noinline)) short
foo (int a, long long int b, short c)
{
  return a + b + c;
}

__attribute__((noinline, noclone)) void
bar (int x)
{
  int i;
  if (x == 0)
    {
    #pragma omp simd
      for (i = 0; i < N; i++)
	c[i] = foo (a[i], b[i], c[i]);
    }
  else
    {
    #pragma omp simd
      for (i = 0; i < N; i++)
	c[i] = foo (a[i], x, i * 3);
    }
}

__attribute__((noinline, noclone)) void
baz (void)
{
  int i;
  for (i = 0; i < N; i++)
    {
      a[i] = 2 * i;
      b[i] = -7 * i + 6;
      c[i] = (i & 31) << 4;
    }
}

int
main ()
{
  int i;
  check_vect ();
  baz ();
  bar (0);
  for (i = 0; i < N; i++)
    if (a[i] != 2 * i || b[i] != 6 - 7 * i
	|| c[i] != 6 - 5 * i + ((i & 31) << 4))
      abort ();
    else
      a[i] = c[i];
  bar (17);
  for (i = 0; i < N; i++)
    if (a[i] != 6 - 5 * i + ((i & 31) << 4)
	|| b[i] != 6 - 7 * i
	|| c[i] != 23 - 2 * i + ((i & 31) << 4))
      abort ();
  return 0;
}

/* { dg-final { cleanup-tree-dump "vect" } } */