https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100393

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Samples: 847K of event 'cycles:u', Event count (approx.): 839745061761          
Overhead       Samples  Command  Shared Object     Symbol                       
  95.05%        804298  cc1      cc1               [.]
tree_switch_conversion::jump_table_cluster::can_be_handled
   1.69%         14493  cc1      cc1               [.]
tree_switch_conversion::cluster::get_range
   0.86%          7291  cc1      cc1               [.]
optimize_function_for_size_p

looks like there's obvious quadraticness here when doing the summing:

bool
jump_table_cluster::can_be_handled (const vec<cluster *> &clusters,
                                    unsigned start, unsigned end)
{
..
  for (unsigned i = start; i <= end; i++)
    {
      simple_cluster *sc = static_cast<simple_cluster *> (clusters[i]);
      comparison_count += sc->m_range_p ? 2 : 1;
    }

and we're almost trying all possible clusters in
jump_table_cluster::find_jump_tables

Now, there's the possibility of doing a quick guess before doing this
loop, once via using (end - start) and once via using 2 * (end - start).
Only if the first can be handled and the second not we have to compute.

Martin?

Reply via email to