<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/62947>62947</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[consteval] The mixed use of 'consteval' and 'constexpr' takes longer time to compile
</td>
</tr>
<tr>
<th>Labels</th>
<td>
c++20,
consteval
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ChuanqiXu9
</td>
</tr>
</table>
<pre>
The reproducer:
```
// Fib.cpp
namespace Fibonacci
{
constexpr unsigned long Recursive(unsigned long n)
{
if (n == 0)
return 0;
if (n == 1)
return 1;
return Recursive(n - 2) + Recursive(n - 1);
}
template<unsigned long N>
struct Number{};
struct DefaultStrategy
{
constexpr unsigned long operator()(unsigned long n, auto... other) const
{
return (n + ... + other);
}
};
template<unsigned long N, typename Strategy = DefaultStrategy>
constexpr unsigned long Cache = Compute(Number<N>{}, Strategy{});
}
namespace Fibonacci
{
constexpr unsigned long Compute(Number<30ul>, auto strategy)
{
return strategy(Recursive(30ul));
}
template constexpr unsigned long Cache<30ul>;
}
```
Let's run:
```
time clang++ -std=c++20 -fconstexpr-steps=4294967295 -c Fib.cpp
```
in my computer it shows:
```
real 0m8.070s
user 0m7.968s
sys 0m0.011s
```
But if I change `Recursive` into consteval, the result will be:
```
$time clang++ -std=c++20 -fconstexpr-steps=4294967295 -c Fib.cpp
real 0m16.145s
user 0m15.948s
sys 0m0.012s
```
it shows now it takes double times to compile the source.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyslUuPgzYQxz-NcxkFGfM-cGhCI1Wq9tD20KtjJsEtYOrH7ubbV3ZesJuklVoJgRg8w39-fz-4MfI4ItYk25CsWXFnO6Xrbef4-Jf83VWrvWpP9W8dgsZJq9YJ1CT5gdCG0Os9p5fr_Mp2hO1gJ_eRmKZzbOQDmokL9GE1ciHkZXCxuZaqhBqNxc9JgxuDqhZ6NR7hFxROG_mOhJXL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