https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84740
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org Assignee|marxin at gcc dot gnu.org |jakub at gcc dot gnu.org --- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Untested fix: --- gcc/tree-switch-conversion.c.jj 2018-01-09 08:58:15.000000000 +0100 +++ gcc/tree-switch-conversion.c 2018-03-07 12:03:42.228246408 +0100 @@ -1563,7 +1563,8 @@ process_switch (gswitch *swtch) gather_default_values (info.default_case_nonstandard ? gimple_switch_label (swtch, 1) : gimple_switch_default_label (swtch), &info); - build_constructors (swtch, &info); + if (info.phi_count) + build_constructors (swtch, &info); build_arrays (swtch, &info); /* Build the static arrays and assignments. */ gen_inbound_check (swtch, &info); /* Build the bounds check. */ I think it is better to do this rather than if (info.phi_count) return "no non-virtual phis"; before create_temp_arrays, because this way we optimize the switch into if, while otherwise we don't. Most of the functions will not really do much, e.g. allocate 0 elts arrays, etc., but only build_constructors relies on info->phi_count > 0.