aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/vect/vect-gather-4.c
blob: edd9a6783c256ec4b8f9492e00d78df3653361fb (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
/* { dg-do compile } */

#define N 16

void
f1 (int *restrict y, int *restrict x1, int *restrict x2,
    int *restrict indices)
{
  for (int i = 0; i < N; ++i)
    {
      y[i * 2] = (indices[i * 2] < N * 2
		  ? x1[indices[i * 2]] + 1
		  : 1);
      y[i * 2 + 1] = (indices[i * 2 + 1] < N * 2
		      ? x2[indices[i * 2 + 1]] + 2
		      : 2);
    }
}

void
f2 (int *restrict y, int *restrict x, int *restrict indices)
{
  for (int i = 0; i < N; ++i)
    {
      y[i * 2] = (indices[i * 2] < N * 2
		  ? x[indices[i * 2]] + 1
		  : 1);
      y[i * 2 + 1] = (indices[i * 2 + 1] < N * 2
		      ? x[indices[i * 2 + 1] * 2] + 2
		      : 2);
    }
}

void
f3 (int *restrict y, int *restrict x, int *restrict indices)
{
  for (int i = 0; i < N; ++i)
    {
      y[i * 2] = (indices[i * 2] < N * 2
		  ? x[indices[i * 2]] + 1
		  : 1);
      y[i * 2 + 1] = (((unsigned int *)indices)[i * 2 + 1] < N * 2
		      ? x[((unsigned int *) indices)[i * 2 + 1]] + 2
		      : 2);
    }
}

/* We do not want to see a two-lane .MASK_LOAD or .MASK_GATHER_LOAD since
   the gathers are different on each lane.  This is a bit fragile and
   should possibly be turned into a runtime test.  */
/* { dg-final { scan-tree-dump-not "stmt 1 \[^\r\n\]* = .MASK" vect } } */