aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/vect/vect-gather-1.c
blob: 5f6640d9ab65a4b126e989e784d0d7a95745b732 (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
#include "tree-vect.h"

#define N 16

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

int y[N * 2];
int x[N * 2] = {
  72704, 52152, 51301, 96681,
  57937, 60490, 34504, 60944,
  42225, 28333, 88336, 74300,
  29250, 20484, 38852, 91536,
  86917, 63941, 31590, 21998,
  22419, 26974, 28668, 13968,
  3451, 20247, 44089, 85521,
  22871, 87362, 50555, 85939
};
int indices[N * 2] = {
  15, 16, 9, 19,
  7, 22, 19, 1,
  22, 13, 15, 30,
  5, 12, 11, 11,
  10, 25, 5, 20,
  22, 24, 24, 28,
  30, 19, 6, 4,
  7, 12, 8, 21
};
int expected[N * 2] = {
  91537, 86919, 28334, 22000,
  60945, 28670, 21999, 52154,
  28669, 20486, 91537, 50557,
  60491, 29252, 74301, 74302,
  88337, 20249, 60491, 22421,
  28669, 3453, 3452, 22873,
  50556, 22000, 34505, 57939,
  60945, 29252, 42226, 26976
};

int
main (void)
{
  check_vect ();

  f (y, x, indices);
#pragma GCC novector
  for (int i = 0; i < 32; ++i)
    if (y[i] != expected[i])
      __builtin_abort ();

  return 0;
}

/* { dg-final { scan-tree-dump "Loop contains only SLP stmts" vect } } */