https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100393
Bug ID: 100393 Summary: Very slow compilation of switch statement with thousands of cases Product: gcc Version: 10.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: curiousdannii at gmail dot com Target Milestone: --- I have a switch statement with almost 11,000 cases (produced by a decompiler), which is taking almost 5 minutes to compile with GCC 10.2. Helpful people on Stack Overflow suggested that it was a regression, that it only took 3 seconds to compile with GCC 8.4, and for comparison, only 1.3 seconds in Clang. I haven't been able to confirm those results yet, but I'll look into doing so. SO discussion: https://stackoverflow.com/q/67363813/2854284 Preprocessed source: https://gist.githubusercontent.com/curiousdannii/9476375ff3ae22c403ce2a8132e6a5dc/raw/568f519f2f1b599e98c514f3609a4968d4153eed/functions_unsafe.i The `-ftime-report -ftime-report-details` results (full results in the SO page) show that the slow part is in "tree switch lowering". I also tried compiling it with `-fno-jump-tables`, which, rather than helping, made it much worse, taking over 33 minutes to compile.