aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common/musttail26.c
blob: 3d0f8c97d9b3c585bb4696235ea4be1ffa0c2202 (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
/* PR ipa/119376 */
/* { dg-do compile { target musttail } } */
/* { dg-options "-O2 -fdump-tree-optimized" } */
/* { dg-final { scan-tree-dump-times "  \[^\n\r]* = foo \\\(3, \[^\n\r]*\\\); \\\[tail call\\\] \\\[must tail call\\\]" 1 "optimized" } } */
/* { dg-final { scan-tree-dump-times "  \[^\n\r]* = foo \\\(4, \[^\n\r]*\\\); \\\[tail call\\\] \\\[must tail call\\\]" 1 "optimized" } } */
/* { dg-final { scan-tree-dump-not "  foo \\\(\[12], \[^\n\r]*\\\); \\\[tail call\\\]" "optimized" } } */

int foo (int, int);
int v, w[10];

static inline __attribute__((always_inline)) int
bar (int x, int y)
{
  [[gnu::musttail]] return foo (x, y);
}

static int
baz (int x, int y)
{
  [[gnu::musttail]] return foo (x, x + y + (v | y) * (v & y));
}

int
qux (int x, int y)
{
  w[0] = bar (1, x + y);
  w[1] = baz (2, x + y);
  if (x == 42)
    [[gnu::musttail]] return bar (3, x + y);
  if (x == -42)
    [[gnu::musttail]] return baz (4, x + y);
  return 0;
}