Debian Codegraph @

gcc/testsuite/gcc.target/powerpc/pr96787-1.c

raw
1 /* { dg-do compile } */
2 /* { dg-require-effective-target powerpc_elfv2 } */
3 /* { dg-require-effective-target power10_ok } */
4 /* { dg-options "-O2 -mdejagnu-cpu=power10" } */
5
6 /* Verify that we generate an indirect sibcall for ELFv2 on P10 and
7 later, with r12 and CTR containing the function address. PR96787. */
8
9 extern int f (int);
10
11 int main ()
12 {
13 if (f (3) != 6)
14 return 1;
15 return 0;
16 }
17
18
19 int g (int a)
20 {
21 return a * 2;
22 }
23
24
25 int h (int a)
26 {
27 return a + 2;
28 }
29
30 int __attribute__((__noinline__)) f (int a)
31 {
32 int (*x) (int) = a % 2 ? &g : &h;
33 (*x) (a);
34 }
35
36 /* { dg-final { scan-assembler {\mmtctr 12\M} } } */
37 /* { dg-final { scan-assembler {\mbctr\M} } } */
38 /* { dg-final { scan-assembler-not {\mbctrl\M} } } */