aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common/musttail25.c
blob: ab286984fc691f4c249c0fd63166ec52aa9125d1 (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
/* PR c/119311 */
/* { dg-do compile { target musttail } } */
/* { dg-options "-O2 -fdump-tree-optimized" } */
/* { dg-final { scan-tree-dump-times "  \[^\n\r]* = bar \\\(\[^\n\r]*\\\); \\\[tail call\\\] \\\[must tail call\\\]" 1 "optimized" } } */
/* { dg-final { scan-tree-dump-times "  \[^\n\r]* = baz \\\(\[^\n\r]*\\\); \\\[tail call\\\] \\\[must tail call\\\]" 1 "optimized" } } */
/* { dg-final { scan-tree-dump-not "  (?:bar|baz) \\\(\[^\n\r]*\\\); \\\[tail call\\\]" "optimized" } } */


[[gnu::noipa]] int
bar (int x, int y)
{
  return x + y;
}

[[gnu::noipa]] int
baz (int x, int y)
{
  return x * y;
}

int
foo (int a, int b)
{
  if (a > b)
    [[gnu::musttail]] return bar (a - b, b);
  else
    [[gnu::musttail]] return baz (a, b - a);
}