aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/s390/nobp-return-mem-z10.c
blob: 177fc32c24bc06a72dd85a73390736f50f04d803 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/* { dg-do run } */
/* { dg-options "-O3 -march=z10 -mzarch --save-temps -mfunction-return-mem=thunk -mindirect-branch-table" } */

int gl = 0;

int __attribute__((noinline,noclone))
bar (int a)
{
  return a + 2;
}

void __attribute__((noinline,noclone))
foo (int a)
{
  int i;

  if (a == 42)
    return;

  for (i = 0; i < a; i++)
    gl += bar (i);
}

int
main ()
{
  foo (3);
  if (gl != 9)
    __builtin_abort ();

  return 0;
}

/* With -march=z10 -mzarch the shrink wrapped returns use compare and
   swap relative to jump to the exit block instead of making use of
   the conditional return pattern.
   FIXME: Use compare and branch register for that!!!! */

/* 2 x foo, 1 x main
/* { dg-final { scan-assembler-times "jg\t__s390_indirect_jump" 3 } } */
/* { dg-final { scan-assembler "exrl" } } */

/* { dg-final { scan-assembler-not "section\t.s390_indirect_jump" } } */
/* { dg-final { scan-assembler-not "section\t.s390_indirect_call" } } */
/* { dg-final { scan-assembler-not "section\t.s390_return_reg" } } */
/* { dg-final { scan-assembler     "section\t.s390_return_mem" } } */