Imported Upstream version 4.8.1
[platform/upstream/gcc48.git] / gcc / testsuite / gcc.target / sh / pr54760-4.c
1 /* Check that the GBR address optimization does not combine a gbr store
2    and its use when a function call is inbetween, when GBR is a call used
3    register, i.e. it is invalidated by function calls.  */
4 /* { dg-do compile { target "sh*-*-*" } } */
5 /* { dg-options "-O1 -fcall-used-gbr" } */
6 /* { dg-skip-if "" { "sh*-*-*" } { "-m5*"} { "" } }  */
7 /* { dg-final { scan-assembler "stc\tgbr" } } */
8
9 extern int test00 (void);
10 int
11 test01 (int x)
12 {
13   /* We must see a stc gbr,rn before the function call, because
14      a function call could modify the gbr.  In this case the user requests
15      the old gbr value, before the function call.  */
16   int* p = (int*)__builtin_thread_pointer ();
17   p[5] = test00 ();
18   return 0;
19 }