aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/vect/pr101145.inc
blob: 615d2e5e55276b891dc3248e87fb7fb754f75b2b (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
TYPE __attribute__ ((noinline))
foo_sign (int *__restrict__ a, int *__restrict__ b, TYPE l, TYPE n)
{
  TYPE i;
  for (i = l; n < i; i += C)
    *a++ = *b++ + 1;
  return i;
}

TYPE __attribute__ ((noinline))
bar_sign (int *__restrict__ a, int *__restrict__ b, TYPE l, TYPE n)
{
  TYPE i;
  for (i = l; i < n; i -= C)
    *a++ = *b++ + 1;
  return i;
}

int __attribute__ ((noinline)) neq (int a, int b) { return a != b; }

int a[1000], b[1000];
int fail;

int
main ()
{
  TYPE res;
  TYPE l;
  TYPE n;
  n = N_BASE;
  l = n - C;
  res = foo_sign (a, b, l, n);
  if (res != l)
    fail++;

  l = n;
  res = foo_sign (a, b, l, n);
  if (res != l)
    fail++;

  l = n + C;
  res = foo_sign (a, b, l, n);
  if (neq ((res - MIN) / C, 0))
    fail++;

  n = N_BASE_DOWN;
  l = n - C;
  res = bar_sign (a, b, l, n);
  if (neq ((MAX - res) / C, 0))
    fail++;

  l = n;
  res = bar_sign (a, b, l, n);
  if (res != l)
    fail++;

  l = n + C;
  res = bar_sign (a, b, l, n);
  if (res != l)
    fail++;

  if (fail)
    __builtin_abort ();
  return 0;
}