OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [tree-ssa/] [tailrecursion-7.c] - Rev 689

Compare with Previous | Blame | View Log

/* { dg-do run } */
/* { dg-options "-O1 -foptimize-sibling-calls -fdump-tree-optimized" } */
 
extern void abort (void);
extern void exit (int);
 
int foo (int n)
{
  return n == 0 ? 1 : n * (n - foo (n - 1));
}
 
int bar (int n)
{
  return n == 0 ? 1 : n * (- bar (n - 1));
}
 
int baz (int n, int m)
{
  return n == 0 ? 100 : (baz (n - 1, m) - m);
}
 
int main (void)
{
  if (foo (6) != 726)
    abort ();
 
  if (bar (7) != -5040)
    abort ();
 
  if (baz (10, 5) != 50)
    abort ();
 
  exit (0);
}
 
/* { dg-final { scan-tree-dump-times "\\mfoo\\M" 4 "optimized"} } */
/* { dg-final { scan-tree-dump-times "\\mbar\\M" 4 "optimized"} } */
/* { dg-final { scan-tree-dump-times "\\mbaz\\M" 4 "optimized"} } */
 
/* { dg-final { cleanup-tree-dump "optimized" } } */
 

Compare with Previous | Blame | View Log

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.