PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / pr51933.c
blob24abc9f1b83f04090ec2711db7a7a2a6021ceb17
1 /* PR rtl-optimization/51933 */
3 static signed char v1;
4 static unsigned char v2[256], v3[256];
6 __attribute__((noclone, noinline)) void
7 foo (void)
9 #if defined(__s390__) && !defined(__zarch__)
10 /* S/390 31 bit cannot deal with more than one literal pool
11 reference per insn. */
12 asm volatile ("" : : "g" (&v1) : "memory");
13 asm volatile ("" : : "g" (&v2[0]));
14 asm volatile ("" : : "g" (&v3[0]));
15 #else
16 asm volatile ("" : : "g" (&v1), "g" (&v2[0]), "g" (&v3[0]) : "memory");
17 #endif
20 __attribute__((noclone, noinline)) int
21 bar (const int x, const unsigned short *y, char *z)
23 int i;
24 unsigned short u;
25 if (!v1)
26 foo ();
27 for (i = 0; i < x; i++)
29 u = y[i];
30 z[i] = u < 0x0100 ? v2[u] : v3[u & 0xff];
32 z[x] = '\0';
33 return x;
36 int
37 main (void)
39 char buf[18];
40 unsigned short s[18];
41 unsigned char c[18] = "abcdefghijklmnopq";
42 int i;
43 for (i = 0; i < 256; i++)
45 v2[i] = i;
46 v3[i] = i + 1;
48 for (i = 0; i < 18; i++)
49 s[i] = c[i];
50 s[5] |= 0x600;
51 s[6] |= 0x500;
52 s[11] |= 0x2000;
53 s[15] |= 0x500;
54 foo ();
55 if (bar (17, s, buf) != 17
56 || __builtin_memcmp (buf, "abcdeghhijkmmnoqq", 18) != 0)
57 __builtin_abort ();
58 return 0;