OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [gcc.dg/] [minmax-1.c] - Blame information for rev 149

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
/* { dg-do run } */
2
/* { dg-options "-fdump-tree-original" } */
3
 
4
/* Check that MIN-MAX and MAX-MIN combinations are folded.  */
5
 
6
extern void abort (void);
7
 
8
#define MIN(a,b) ((a) < (b) ? (a) : (b))
9
#define MAX(a,b) ((a) > (b) ? (a) : (b))
10
 
11
int f1(int a, int b)
12
{
13
   return MIN (MAX (a, b), b); /* == b */
14
}
15
 
16
int f2(int a, int b)
17
{
18
   return MAX (MIN (a, b), b); /* == b */
19
}
20
 
21
int f3(int a, int b)
22
{
23
   return MIN (MAX (b, a), b); /* == b */
24
}
25
 
26
int f4(int a, int b)
27
{
28
   return MAX (MIN (b, a), b); /* == b */
29
}
30
 
31
 
32
int g1(int a, int b)
33
{
34
   return MIN (a, MAX (a, b)); /* == a */
35
}
36
 
37
int g2(int a, int b)
38
{
39
   return MAX (a, MIN (a, b)); /* == a */
40
}
41
 
42
int g3(int a, int b)
43
{
44
   return MIN (a, MAX (b, a)); /* == a */
45
}
46
 
47
int g4(int a, int b)
48
{
49
   return MAX (a, MIN (b, a)); /* == a */
50
}
51
 
52
int main(void)
53
{
54
  if (f1 (1, 2) != 2)
55
    abort ();
56
 
57
  if (f2 (1, 2) != 2)
58
    abort ();
59
 
60
  if (f3 (1, 2) != 2)
61
    abort ();
62
 
63
  if (f4 (1, 2) != 2)
64
    abort ();
65
 
66
  if (g1 (1, 2) != 1)
67
    abort ();
68
 
69
  if (g2 (1, 2) != 1)
70
    abort ();
71
 
72
  if (g3 (1, 2) != 1)
73
    abort ();
74
 
75
  if (g4 (1, 2) != 1)
76
    abort ();
77
 
78
  return 0;
79
}
80
 
81
/* { dg-final { scan-tree-dump-times "MIN_EXPR" 0 "original"} } */
82
/* { dg-final { scan-tree-dump-times "MAX_EXPR" 0 "original"} } */
83
/* { dg-final { cleanup-tree-dump "original" } } */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.