testsuite: add testcase for fixed PR106073
[official-gcc.git] / gcc / testsuite / gcc.target / s390 / 20090223-1.c
blob18355f990e5f939bd90e2a07d14a698c3e3fe5fc
1 /* The RTL loop optimizer used to replace the output register of the
2 inline assembly with a pseudo although the variable is declared as
3 register asm ("0"). */
5 /* { dg-do run } */
6 /* { dg-options "-O2 -Wno-attributes -Wno-implicit-function-declaration" } */
8 extern void abort (void);
10 static unsigned char __attribute__ ((always_inline))
11 mytoupper (unsigned char c)
13 if (c >= 'a' && c <= 'z')
14 c -= 'a' - 'A';
15 return c;
18 static unsigned long __attribute__ ((always_inline))
19 strlen (const char *s)
21 register unsigned long r0 asm ("0");
22 const char *tmp = s;
24 asm (
25 #ifdef __s390x__
26 " lghi %0, 0\n"
27 #else
28 " lhi %0, 0\n"
29 #endif
30 "0:srst %0,%1\n"
31 " jo 0b"
32 : "=d" (r0), "+a" (tmp)
34 :"cc");
35 return r0 - (unsigned long) s;
38 char boot_command_line[] = "this is a test";
40 void __attribute__ ((noinline))
41 foo (char *str)
43 if (strcmp (str, "THIS IS A TEST") != 0)
44 abort ();
47 int
48 main ()
50 char upper_command_line[1024];
51 int i;
53 for (i = 0; i < strlen (boot_command_line); i++)
54 upper_command_line[i] = mytoupper (boot_command_line[i]);
56 upper_command_line[strlen (boot_command_line)] = 0;
57 foo (upper_command_line);
59 return 0;