https://llvm.org/bugs/show_bug.cgi?id=25729
Richard Smith <richard-l...@metafoo.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |DUPLICATE --- Comment #2 from Richard Smith <richard-l...@metafoo.co.uk> --- The code is obviously exponential-time in Index: template <unsigned Index> constexpr unsigned crc32 (char const * str) { unsigned const a = crc32 <Index - 1> (str) >> 8; unsigned const b = crc32 <Index - 1> (str) ^ str [Index - 1]; return a ^ crc_table [b & 0x000000FF]; } Don't compute crc32<Index - 1>(str) twice, compute it once and reuse the result. I don't know why people expect to get asymptotic performance improvements by slapping 'constexpr' on their functions, and I'm not convinced GCC's memoization is doing anyone any favours here -- if we or GCC choose to evaluate the initializer at runtime (as we are permitted to do), it will also be extremely slow (in a -O0 build at least), due to the use of a ridiculous exponential-time algorithm. *** This bug has been marked as a duplicate of bug 12850 *** -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs