File: pr67089-2.c

package info (click to toggle)
gcc-riscv64-unknown-elf 8.3.0.2019.08%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 680,956 kB
  • sloc: ansic: 3,237,715; cpp: 896,882; ada: 772,854; f90: 144,254; asm: 68,788; makefile: 67,456; sh: 29,743; exp: 28,045; objc: 15,273; fortran: 11,885; python: 7,369; pascal: 5,375; awk: 3,725; perl: 2,872; yacc: 316; xml: 311; ml: 285; lex: 198; haskell: 122
file content (112 lines) | stat: -rw-r--r-- 4,446 bytes parent folder | download | duplicates (6)
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/* PR target/67089 */
/* { dg-do run } */
/* { dg-options "-O2" } */

extern void abort (void);

int cnt, d;

__attribute__((noinline, noclone))
void foo (int x)
{
  asm volatile ("" : "+m" (d) : "g" (x) : "memory");
  cnt++;
}

#define T(n, type, op, cond) \
__attribute__((noinline, noclone))	\
type					\
f##n (type x, type y)			\
{					\
  type r = op;				\
  cond;					\
  return r;				\
}

T (1, unsigned int, x - y, if (r > y) foo (0))
T (2, unsigned long, x - y, if (r <= y) foo (0))
T (3, unsigned short, x - y, if (y < r) foo (r))
T (4, unsigned long long, x - y, if (y >= r) foo (0))
T (5, unsigned int, x - y, if (r >= y) foo (0))
T (6, unsigned long, x - y, if (r < y) foo (0))
T (7, unsigned short, x - y, if (y <= r) foo (r))
T (8, unsigned long long, x - y, if (d || y > r) foo (0))
T (9, unsigned int, x - y, if (d || r > y) foo (0))
T (10, unsigned long, x - y, if (d || r <= y) foo (0))
T (11, unsigned char, x - y, if (d || y < r) foo (0))
T (12, unsigned long long, x - y, if (d || y >= r) foo (0))
T (13, unsigned int, x - y, if (d || r >= y) foo (0))
T (14, unsigned long, x - y, if (d || r < y) foo (0))
T (15, unsigned short, x - y, if (d || y <= r) foo (0))
T (16, unsigned long long, x - y, if (d || y > r) foo (0))

int
main ()
{
  if (f1 (5, 3) != 2U || cnt != 0) abort ();
  if (f1 (5, 7) != -2U || cnt != 1) abort ();
  if (f1 (5, 5) != 0U || cnt != 1) abort ();
  if (f1 (5, 0) != 5U || cnt != 2) abort ();
  if (f2 (7, 1) != 6UL || cnt != 2) abort ();
  if (f2 (7, 8) != -1UL || cnt != 2) abort ();
  if (f2 (9, 9) != 0UL || cnt != 3) abort ();
  if (f2 (9, 0) != 9UL || cnt != 3) abort ();
  if (f3 (15, 14) != 1 || cnt != 3) abort ();
  if (f3 (15, 25) != (unsigned short) -10 || cnt != 4) abort ();
  if (f3 (15, 15) != 0 || cnt != 4) abort ();
  if (f3 (15, 0) != 15 || cnt != 5) abort ();
  if (f4 (9132, 9127) != 5ULL || cnt != 6) abort ();
  if (f4 (9132, 9137) != -5ULL || cnt != 6) abort ();
  if (f4 (9132, 9132) != 0 || cnt != 7) abort ();
  if (f4 (9132, 0) != 9132ULL || cnt != 7) abort ();
  if (f5 (5, 3) != 2U || cnt != 7) abort ();
  if (f5 (5, 7) != -2U || cnt != 8) abort ();
  if (f5 (5, 5) != 0U || cnt != 8) abort ();
  if (f5 (5, 0) != 5U || cnt != 9) abort ();
  if (f6 (7, 1) != 6UL || cnt != 9) abort ();
  if (f6 (7, 8) != -1UL || cnt != 9) abort ();
  if (f6 (9, 9) != 0UL || cnt != 10) abort ();
  if (f6 (9, 0) != 9UL || cnt != 10) abort ();
  if (f7 (15, 14) != 1 || cnt != 10) abort ();
  if (f7 (15, 25) != (unsigned short) -10 || cnt != 11) abort ();
  if (f7 (15, 15) != 0 || cnt != 11) abort ();
  if (f7 (15, 0) != 15 || cnt != 12) abort ();
  if (f8 (9132, 9127) != 5ULL || cnt != 13) abort ();
  if (f8 (9132, 9137) != -5ULL || cnt != 13) abort ();
  if (f8 (9132, 9132) != 0 || cnt != 14) abort ();
  if (f8 (9132, 0) != 9132ULL || cnt != 14) abort ();
  cnt = 0;
  if (f9 (5, 3) != 2U || cnt != 0) abort ();
  if (f9 (5, 7) != -2U || cnt != 1) abort ();
  if (f9 (5, 5) != 0U || cnt != 1) abort ();
  if (f9 (5, 0) != 5U || cnt != 2) abort ();
  if (f10 (7, 1) != 6UL || cnt != 2) abort ();
  if (f10 (7, 8) != -1UL || cnt != 2) abort ();
  if (f10 (9, 9) != 0UL || cnt != 3) abort ();
  if (f10 (9, 0) != 9UL || cnt != 3) abort ();
  if (f11 (15, 14) != 1 || cnt != 3) abort ();
  if (f11 (15, 25) != (unsigned char) -10 || cnt != 4) abort ();
  if (f11 (15, 15) != 0 || cnt != 4) abort ();
  if (f11 (15, 0) != 15 || cnt != 5) abort ();
  if (f12 (9132, 9127) != 5ULL || cnt != 6) abort ();
  if (f12 (9132, 9137) != -5ULL || cnt != 6) abort ();
  if (f12 (9132, 9132) != 0 || cnt != 7) abort ();
  if (f12 (9132, 0) != 9132ULL || cnt != 7) abort ();
  if (f13 (5, 3) != 2U || cnt != 7) abort ();
  if (f13 (5, 7) != -2U || cnt != 8) abort ();
  if (f13 (5, 5) != 0U || cnt != 8) abort ();
  if (f13 (5, 0) != 5U || cnt != 9) abort ();
  if (f14 (7, 1) != 6UL || cnt != 9) abort ();
  if (f14 (7, 8) != -1UL || cnt != 9) abort ();
  if (f14 (9, 9) != 0UL || cnt != 10) abort ();
  if (f14 (9, 0) != 9UL || cnt != 10) abort ();
  if (f15 (15, 14) != 1 || cnt != 10) abort ();
  if (f15 (15, 25) != (unsigned short) -10 || cnt != 11) abort ();
  if (f15 (15, 15) != 0 || cnt != 11) abort ();
  if (f15 (15, 0) != 15 || cnt != 12) abort ();
  if (f16 (9132, 9127) != 5ULL || cnt != 13) abort ();
  if (f16 (9132, 9137) != -5ULL || cnt != 13) abort ();
  if (f16 (9132, 9132) != 0 || cnt != 14) abort ();
  if (f16 (9132, 0) != 9132ULL || cnt != 14) abort ();
  return 0;
}