comparison gcc/testsuite/gcc.dg/pr67089-5.c @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children
comparison
equal deleted inserted replaced
68:561a7518be6b 111:04ced10e8804
1 /* PR target/67089 */
2 /* { dg-do run } */
3 /* { dg-options "-O2 -ftree-loop-if-convert" } */
4
5 extern void abort (void);
6
7 int cnt;
8 unsigned int a[16], b[16], c[16];
9
10 __attribute__((noinline, noclone))
11 void foo (int x)
12 {
13 asm volatile ("" : : "g" (x) : "memory");
14 cnt++;
15 }
16
17 __attribute__((noinline, noclone)) void
18 f0 (unsigned int x)
19 {
20 for (int i = 0; i < 16; i++)
21 {
22 unsigned int r = x - a[i];
23 b[i] = r;
24 c[i] = r > x ? 7 : x;
25 }
26 }
27
28 #define T(n, type, op, cond) \
29 __attribute__((noinline, noclone)) \
30 type \
31 f##n (type x) \
32 { \
33 type r = op; \
34 cond; \
35 return r; \
36 }
37
38 T (1, unsigned int, x - 2U, if (r > x) foo (0))
39 T (2, unsigned long, x - 2U, if (r <= x) foo (0))
40 T (3, unsigned short, 2U - x, if (r > 2U) foo (0))
41 T (4, unsigned char, 2U - x, if (r <= 2U) foo (0))
42 T (5, unsigned int, x + -2U, if (r > x) foo (0))
43 T (6, unsigned long, x + -2UL, if (r <= x) foo (0))
44 T (7, unsigned short, (unsigned short) -2 + x, if (r > (unsigned short) -2) foo (0))
45 T (8, unsigned char, (unsigned char) -2 + x, if (r <= (unsigned char) -2) foo (0))
46
47 int
48 main ()
49 {
50 int i;
51 for (i = 0; i < 16; i++)
52 a[i] = i - 7;
53 f0 (5);
54 for (i = 0; i < 16; i++)
55 if (b[i] != 12U - i || c[i] != 7 - 2 * (i >= 7 && i < 13))
56 abort ();
57 if (f1 (3) != 1 || cnt != 0) abort ();
58 if (f1 (2) != 0 || cnt != 0) abort ();
59 if (f1 (1) != -1U || cnt != 1) abort ();
60 if (f2 (3) != 1 || cnt != 2) abort ();
61 if (f2 (2) != 0 || cnt != 3) abort ();
62 if (f2 (1) != -1UL || cnt != 3) abort ();
63 if (f3 (3) != (unsigned short) -1 || cnt != 4) abort ();
64 if (f3 (2) != 0 || cnt != 4) abort ();
65 if (f3 (1) != 1 || cnt != 4) abort ();
66 if (f4 (3) != (unsigned char) -1 || cnt != 4) abort ();
67 if (f4 (2) != 0 || cnt != 5) abort ();
68 if (f4 (1) != 1 || cnt != 6) abort ();
69 if (f5 (3) != 1 || cnt != 6) abort ();
70 if (f5 (2) != 0 || cnt != 6) abort ();
71 if (f5 (1) != -1U || cnt != 7) abort ();
72 if (f6 (3) != 1 || cnt != 8) abort ();
73 if (f6 (2) != 0 || cnt != 9) abort ();
74 if (f6 (1) != -1UL || cnt != 9) abort ();
75 if (f7 (3) != 1 || cnt != 9) abort ();
76 if (f7 (2) != 0 || cnt != 9) abort ();
77 if (f7 (1) != (unsigned short) -1 || cnt != 10) abort ();
78 if (f8 (3) != 1 || cnt != 11) abort ();
79 if (f8 (2) != 0 || cnt != 12) abort ();
80 if (f8 (1) != (unsigned char) -1 || cnt != 12) abort ();
81 return 0;
82 }