This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/78484] New: if-else chain is not turned into a local jump table
- From: "timshen at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 22 Nov 2016 21:54:17 +0000
- Subject: [Bug c++/78484] New: if-else chain is not turned into a local jump table
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78484
Bug ID: 78484
Summary: if-else chain is not turned into a local jump table
Product: gcc
Version: 7.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: timshen at gcc dot gnu.org
Target Milestone: ---
Convenient link: https://godbolt.org/g/AEYMwC
The following C++ code is slow, since it's not turned into a jump table:
template<int n>
void Foo();
template<int n>
struct BarImpl {
static void Apply(int m) {
if (m == n) {
Foo<n>();
} else {
BarImpl<n-1>::Apply(m);
}
}
};
template<>
struct BarImpl<0> {
static void Apply(int m) {
Foo<0>();
}
};
void Bar(int n) {
BarImpl<30>::Apply(n);
}