From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9B8DB389443C; Mon, 3 May 2021 11:46:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9B8DB389443C From: "curiousdannii at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/100393] New: Very slow compilation of switch statement with thousands of cases Date: Mon, 03 May 2021 11:46:51 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 10.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: curiousdannii at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 May 2021 11:46:51 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D100393 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 decompile= r), 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 seco= nds 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/9476375ff3ae22c403ce2a8132= e6a5dc/raw/568f519f2f1b599e98c514f3609a4968d4153eed/functions_unsafe.i The `-ftime-report -ftime-report-details` results (full results in the SO p= age) show that the slow part is in "tree switch lowering". I also tried compiling it with `-fno-jump-tables`, which, rather than helpi= ng, made it much worse, taking over 33 minutes to compile.=