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); }