blob: 58705277ec553f220a3ca30f18ae55356a3f7b07 (
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
47
48
49
|
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-optimized -fno-ipa-reference" } */
#include <iostream>
namespace {
template <unsigned long long L> class fib {
public:
static const unsigned long long value = fib<L - 1>::value + fib<L - 2>::value;
};
template <> class fib<0> {
public:
static const unsigned long long value = 1;
};
template <> class fib<1> {
public:
static const unsigned long long value = 1;
};
template<unsigned long long L> inline unsigned long long fibconst()
{
return fibconst<L - 1>() + fibconst<L - 2>();
}
template <> inline unsigned long long fibconst<0>()
{
return 1ull;
}
template <> inline unsigned long long fibconst<1>()
{
return 1ull;
}
template <> inline unsigned long long fibconst<2>()
{
return 2ull;
}
}
int main()
{
::std::cerr << "fib<90>::value == " << fib<90>::value << "\n";
::std::cerr << "fibcst<90>() == " << fibconst<90>() << "\n";
}
// { dg-final { scan-tree-dump-not "fibconst" "optimized" } }
// { dg-final { cleanup-tree-dump "optimized" } }
|