summaryrefslogtreecommitdiff
path: root/support/regression/tests/gcc-torture-execute-pr87290.c
blob: 233d685f8cbd097a9e4c3185bda736bf3fcfc16b (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
66
67
68
69
/*
   pr87290.c from the execute part of the gcc torture tests.
 */

#include <testfwk.h>

/* PR middle-end/87290 */

int c;

void
f0 (void)
{
  c++;
}

int
f1 (int x)
{
  return x % 16 == 13;
}

int
f2 (int x)
{
  return x % 16 == -13;
}

void
f3 (int x)
{
  if (x % 16 == 13)
    f0 ();
}

void
f4 (int x)
{
  if (x % 16 == -13)
    f0 ();
}

void
testTortureExecute (void)
{
  int i, j;
  for (i = -30; i < 30; i++)
    {
      if (f1 (13 + i * 16) != (i >= 0) || f2 (-13 + i * 16) != (i <= 0))
	ASSERT (0);
      f3 (13 + i * 16);
      if (c != (i >= 0))
	ASSERT (0);
      f4 (-13 + i * 16);
      if (c != 1 + (i == 0))
	ASSERT (0);
      for (j = 1; j < 16; j++)
	{
	  if (f1 (13 + i * 16 + j) || f2 (-13 + i * 16 + j))
	    ASSERT (0);
	  f3 (13 + i * 16 + j);
	  f4 (-13 + i * 16 + j);
	}
      if (c != 1 + (i == 0))
	ASSERT (0);
      c = 0;
    }
  return;
}