aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/powerpc/pr115355.c
blob: 8955126b80850f5189ec7bac3334b1be3e134355 (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
/* { dg-do run } */
/* { dg-require-effective-target p9vector_hw } */
/* Force vectorization with -fno-vect-cost-model to have vector unpack
   which exposes the issue in PR115355.  */
/* { dg-options "-O2 -mdejagnu-cpu=power9 -fno-vect-cost-model" } */

/* Verify it runs successfully.  */

__attribute__((noipa))
void setToIdentityGOOD(unsigned long long *mVec, unsigned int mLen)
{
  #pragma GCC novector
  for (unsigned int i = 0; i < mLen; i++)
    mVec[i] = i;
}

__attribute__((noipa))
void setToIdentityBAD(unsigned long long *mVec, unsigned int mLen)
{
  for (unsigned int i = 0; i < mLen; i++)
    mVec[i] = i;
}

unsigned long long vec1[100];
unsigned long long vec2[100];

int main()
{
  unsigned int l = 29;
  setToIdentityGOOD (vec1, 29);
  setToIdentityBAD (vec2, 29);

  if (__builtin_memcmp (vec1, vec2, l * sizeof (vec1[0])) != 0)
    __builtin_abort ();

  return 0;
}