aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/tree-ssa/pr109401.c
blob: 11177d97fbf609ccb74c645b290be3cb898640f9 (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
/* PR tree-optimization/109878 */
/* { dg-do compile } */
/* { dg-options "-O1 -fdump-tree-optimized" } */

/* Returns max (a, b) */
int max(int a, int b) {
  if (b > a)
    return b;
  else
    return a;
}

/* Returns min (a, b) */
int min(int a, int b) {
  if (b < a)
    return b;
  else
    return a;
}

/* All the functions here shouldn't evalute min or max of a and b
 * These functions should return a op b */
int f(int a, int b)
{
  return max (a, b) + min (a, b);
}

int f1(int a, int b)
{
  return max (a, b) * min (a, b);
}

int f2(int a, int b)
{
  return max (a, b) | min (a, b);
}

int f3(int a, int b)
{
  return max (a, b) & min (a, b);
}

int f5(int a, int b)
{
  return min (a, b) ^ max (a, b);
}

int f6(int a, int b)
{
  return min (a, b) == max (a, b);
}

int f7(int a, int b)
{
  return min (a, b) != max (a, b);
}

/* Function min should have MIN_EXPR */
/* Function max should have MAX_EXPR */
/* { dg-final { scan-tree-dump-times "MIN_EXPR" 1 "optimized" } } */
/* { dg-final { scan-tree-dump-times "MAX_EXPR" 1 "optimized" } } */