aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/pr108359.c
blob: 7cf04f7413286e86e21261d18e9e8ae686c18aa5 (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
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-optimized" } */

/* PR test case.  */
int b = 10;
int c;
char e;
void foo();
static char(a)(char f, char g) { return f && g == 1 ? 0 : f % g; }
short(d)(short f, short g) { return f * g; }
int main() {
  short h;
  int i;
  unsigned j;
  h = d(b && c, 5);
  j = h;
  i = a(h, 237);
  unsigned k = i;
  e = i < 0 || k >= 32 ? 0 : i >> k;
  if (e) {
    c = 0;
    foo();
  }
}


/* Also Check that small ranges are broken down and optimized properly
   This function should never call foo ().  */

int otherfunc (int x, int z) {
  if (x < 1 || x > 6 )
    return 0;

  if (x == z)
    {
    if (x >> z > 0)
      foo ();
    if (x * z > 26 && x * z < 35)
      foo ();
    if (x + z == 5)
      foo ();
    if ((x + z) % 2 == 1)
      foo ();
    if (x / z != 1)
      foo ();

    }
  return 0;
}


/* { dg-final { scan-tree-dump-not "foo" "optimized" } } */