aboutsummaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.c-c++-common/pr106449-2.c
blob: 7fef7461bcf2422809d5424adba516d69dec62dd (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
/* { dg-do run } */

/* Based on pr106449.c - but using 'for' instead of 'simd'.
   Cf. PR middle-end/106449 (for pr106449.c) and PR middle-end/106467.  */

void
foo (void)
{
  int a[1024], *b[65536], *c[65536];
  int *p, *q, **r = &b[0], **r2 = &c[0], i;
  #pragma omp for collapse(2)
  for (p = &a[0]; p < &a[512]; p++)
    for (q = p + 64; q < p + 128; q++)
      {
	*r++ = p;
	*r2++ = q;
      }
  for (i = 0; i < 32768; i++)
    if (b[i] != &a[i / 64] || c[i] != &a[(i / 64) + 64 + (i % 64)])
      __builtin_abort ();
}

void
bar (int n, int m)
{
  int a[1024], *b[32768], *c[32768];
  int *p, *q, **r = &b[0], **r2 = &c[0], i;
  #pragma omp for collapse(2)
  for (p = &a[0]; p < &a[512]; p++)
    for (q = p + n; q < p + m; q++)
      {
	*r++ = p;
	*r2++ = q;
      }
  for (i = 0; i < 32768; i++)
    if (b[i] != &a[i / 64] || c[i] != &a[(i / 64) + 64 + (i % 64)])
      __builtin_abort ();
}

void
baz (int n, int m)
{
  int a[1024], *b[8192], *c[8192];
  int *p, *q, **r = &b[0], **r2 = &c[0], i;
  #pragma omp for collapse(2)
  for (p = &a[0]; p < &a[512]; p += 4)
    for (q = p + n; q < p + m; q += 2)
      {
	*r++ = p;
	*r2++ = q;
      }
  for (i = 0; i < 4096; i++)
    if (b[i] != &a[(i / 32) * 4] || c[i] != &a[(i / 32) * 4 + 64 + (i % 32) * 2])
      __builtin_abort ();
}

int
main ()
{
  foo ();
  bar (64, 128);
  baz (64, 128);
  return 0;
}