]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gcc.c-torture/execute/20190820-1.c
PR rtl-optimization/91347
[thirdparty/gcc.git] / gcc / testsuite / gcc.c-torture / execute / 20190820-1.c
1 /* PR rtl-optimization/91347 */
2 /* Reported by John David Anglin <danglin@gcc.gnu.org> */
3
4 typedef unsigned short __u16;
5 typedef __signed__ int __s32;
6 typedef unsigned int __u32;
7 typedef __signed__ long long __s64;
8 typedef unsigned long long __u64;
9 typedef __u16 u16;
10 typedef __s32 s32;
11 typedef __u32 u32;
12 typedef __u64 u64;
13 typedef _Bool bool;
14 typedef s32 int32_t;
15 typedef u32 uint32_t;
16 typedef u64 uint64_t;
17
18 char hex_asc_upper[16];
19 u16 decpair[100];
20
21 static __attribute__ ((noipa)) void
22 put_dec_full4 (char *buf, unsigned r)
23 {
24 unsigned q;
25 q = (r * 0x147b) >> 19;
26 *((u16 *)buf) = decpair[r - 100*q];
27 buf += 2;
28 *((u16 *)buf) = decpair[q];
29 }
30
31 static __attribute__ ((noipa)) unsigned
32 put_dec_helper4 (char *buf, unsigned x)
33 {
34 uint32_t q = (x * (uint64_t)0x346DC5D7) >> 43;
35 put_dec_full4(buf, x - q * 10000);
36 return q;
37 }
38
39 static __attribute__ ((noipa)) char *
40 put_dec (char *buf, unsigned long long n)
41 {
42 uint32_t d3, d2, d1, q, h;
43 d1 = ((uint32_t)n >> 16);
44 h = (n >> 32);
45 d2 = (h ) & 0xffff;
46 d3 = (h >> 16);
47 q = 656 * d3 + 7296 * d2 + 5536 * d1 + ((uint32_t)n & 0xffff);
48 q = put_dec_helper4(buf, q);
49 q += 7671 * d3 + 9496 * d2 + 6 * d1;
50 q = put_dec_helper4(buf+4, q);
51 q += 4749 * d3 + 42 * d2;
52 q = put_dec_helper4(buf+8, q);
53 return buf;
54 }
55
56 struct printf_spec {
57 unsigned int type:8;
58 signed int field_width:24;
59 unsigned int flags:8;
60 unsigned int base:8;
61 signed int precision:16;
62 } __attribute__((__packed__));
63
64 static __attribute__ ((noipa)) char *
65 number (char *buf, char *end, unsigned long long num, struct printf_spec spec)
66 {
67
68 char tmp[3 * sizeof(num)] __attribute__((__aligned__(2)));
69 char sign;
70 char locase;
71 int need_pfx = ((spec.flags & 64) && spec.base != 10);
72 int i;
73 bool is_zero = num == 0LL;
74 int field_width = spec.field_width;
75 int precision = spec.precision;
76
77 i = 0;
78 if (num < spec.base)
79 tmp[i++] = hex_asc_upper[num] | locase;
80 else if (spec.base != 10) {
81 int mask = spec.base - 1;
82 int shift = 3;
83 if (spec.base == 16)
84 shift = 4;
85 else
86 __builtin_abort ();
87 do {
88 tmp[i++] = (hex_asc_upper[((unsigned char)num) & mask] | locase);
89 num >>= shift;
90 } while (num);
91 } else {
92 i = put_dec(tmp, num) - tmp;
93 }
94 return buf;
95 }
96
97 static __attribute__ ((noipa)) char *
98 pointer_string (char *buf, char *end, const void *ptr, struct printf_spec spec)
99 {
100 spec.base = 16;
101 spec.flags = 0;
102 return number(buf, end, 100, spec);
103 }
104
105 int
106 main (void)
107 {
108 struct printf_spec spec;
109 char *s = pointer_string (0, 0, 0, spec);
110 return 0;
111 }