aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/tree-ssa/fre-predicated-3.c
blob: 4a89372fd703e70660fbf960b48a750eab7de207 (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
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-optimized" } */

/* PR tree-optimization/117414 */

/* Fre1 should figure out that `*aaa != 0`
   For f0, f1, and f2. */

void foo();
int f(int *aaa, int j, int t)
{
  int b = *aaa;
  int c = b == 0;
  int d = t != 1;
  if (c | d)
    return 0;

  for(int i = 0; i < j; i++)
  {
    if (*aaa)
      ;
    else
      foo();
  }
  return 0;
}

int f1(int *aaa, int j, int t)
{
  int b = *aaa;
  if (b == 0)
    return 0;
  if (t != 1)
    return 0;
  for(int i = 0; i < j; i++)
  {
    if (*aaa)
      ;
    else
      foo();
  }
  return 0;
}

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