aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/vect/pr46032.c
blob: bad87453a7de62024b89561b2dd5c0aa03a71a77 (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
/* { dg-do compile } */
/* { dg-require-effective-target fopenmp } */
/* { dg-require-effective-target vect_int } */
/* { dg-additional-options "-fopenmp -fipa-pta" } */

extern void abort (void);

#define nEvents 1000

static void __attribute__((noinline, noclone, optimize("-fno-tree-vectorize")))
init (unsigned *results, unsigned *pData)
{
  unsigned int i;
  for (i = 0; i < nEvents; ++i)
    pData[i] = i % 3;
}

static void __attribute__((noinline, noclone, optimize("-fno-tree-vectorize")))
check (unsigned *results)
{
  unsigned sum = 0;
  for (int idx = 0; idx < (int)nEvents; idx++)
    sum += results[idx];

  if (sum != 1998)
    abort ();
}

int
main (void)
{
  unsigned results[nEvents];
  unsigned pData[nEvents];
  unsigned coeff = 2;

  init (&results[0], &pData[0]);

#pragma omp parallel for
  for (int idx = 0; idx < (int)nEvents; idx++)
    results[idx] = coeff * pData[idx];

  check (&results[0]);

  return 0;
}

/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { xfail { vect_no_align && { ! vect_hw_misalign } } } } } */
/* { dg-final { scan-tree-dump-not "versioning for alias required" "vect" } } */