summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/i386/pr30315.c
blob: 998d5071e5c0d9f290aac61f3673c9f5b9b31035 (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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/* { dg-do compile } */
/* { dg-options "-O2" } */
/* { dg-final { scan-assembler-times "cmp" 4 } } */

extern void abort (void);
int c;

#define PLUSCC1(T, t, C)	\
T pluscc##t##C (T a, T b)	\
{	\
  T sum = a + b;	\
  if (sum < C)		\
    abort ();		\
  return sum;		\
}
#define PLUSCC(T, t) PLUSCC1(T, t, a) PLUSCC1(T, t, b)

#define INCCC1(T, t, C)	\
T inccc##t##C (T a, T b)	\
{	\
  T sum = a + b;	\
  if (sum < C)		\
    c ++;		\
  return sum;		\
}
#define INCCC(T, t) INCCC1(T, t, a) INCCC1(T, t, b)

#define PLUSCCONLY1(T, t, C)	\
void pluscconly##t##C (T a, T b)	\
{	\
  T sum = a + b;	\
  if (sum < C)		\
    abort ();		\
}
#define PLUSCCONLY(T, t) PLUSCCONLY1(T, t, a) PLUSCCONLY1(T, t, b)

#define MINUSCC(T, t)	\
T minuscc##t (T a, T b)	\
{	\
  T difference = a - b;	\
  if (difference > a)	\
    abort ();		\
  return difference;	\
}

#define DECCC(T, t)	\
T deccc##t (T a, T b)	\
{	\
  T difference = a - b;	\
  if (difference > a)	\
    c --;		\
  return difference;	\
}

#define MINUSCCONLY(T, t)	\
void minuscconly##t (T a, T b)	\
{	\
  T difference = a - b;	\
  if (difference > a)	\
    abort ();		\
}

#define TEST(T, t)	\
  PLUSCC(T, t)		\
  PLUSCCONLY(T, t)	\
  INCCC(T, t)		\
  MINUSCC(T, t)		\
  MINUSCCONLY(T, t)	\
  DECCC(T, t)

TEST (unsigned long,  l)
TEST (unsigned int,   i)
TEST (unsigned short, s) 
TEST (unsigned char,  c)

#define PLUSCCZEXT(C)	\
unsigned long pluscczext##C (unsigned int a, unsigned int b)	\
{	\
  unsigned int sum = a + b;	\
  if (sum < C)		\
    abort ();		\
  return sum;		\
}

PLUSCCZEXT(a)
PLUSCCZEXT(b)

#define MINUSCCZEXT	\
unsigned long minuscczext (unsigned int a, unsigned int b)	\
{	\
  unsigned int difference = a - b;	\
  if (difference > a)		\
    abort ();			\
  return difference;		\
}

MINUSCCZEXT