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
|
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-optimized-raw" } */
int carry;
int f(unsigned a, unsigned b) {
unsigned r;
carry = __builtin_sub_overflow(a, b, &r);
return r > a;
}
int g(unsigned a, unsigned b) {
unsigned r;
carry = __builtin_sub_overflow(a, b, &r);
return a < r;
}
int h(unsigned a, unsigned b) {
unsigned r;
carry = __builtin_sub_overflow(a, b, &r);
return r <= a;
}
int i(unsigned a, unsigned b) {
unsigned r;
carry = __builtin_sub_overflow(a, b, &r);
return a >= r;
}
int j(unsigned a, unsigned b) {
unsigned r;
carry = __builtin_add_overflow(a, b, &r);
return r < a;
}
int j2(unsigned a, unsigned b) {
unsigned r;
carry = __builtin_add_overflow(a, b, &r);
return r < b;
}
int k(unsigned a, unsigned b) {
unsigned r;
carry = __builtin_add_overflow(a, b, &r);
return a > r;
}
int k2(unsigned a, unsigned b) {
unsigned r;
carry = __builtin_add_overflow(a, b, &r);
return b > r;
}
int l(unsigned a, unsigned b) {
unsigned r;
carry = __builtin_add_overflow(a, b, &r);
return r >= a;
}
int l2(unsigned a, unsigned b) {
unsigned r;
carry = __builtin_add_overflow(a, b, &r);
return r >= b;
}
int m(unsigned a, unsigned b) {
unsigned r;
carry = __builtin_add_overflow(a, b, &r);
return a <= r;
}
int m2(unsigned a, unsigned b) {
unsigned r;
carry = __builtin_add_overflow(a, b, &r);
return b <= r;
}
/* { dg-final { scan-tree-dump-not "(le|lt|ge|gt)_expr" "optimized" } } */
/* { dg-final { scan-tree-dump-times "ADD_OVERFLOW" 8 "optimized" } } */
/* { dg-final { scan-tree-dump-times "SUB_OVERFLOW" 4 "optimized" } } */
|