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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|                            |x86_64-*-*
     Ever confirmed|0                           |1
           Keywords|                            |compile-time-hog, ra
                 CC|                            |vmakarov at gcc dot gnu.org
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2026-10-14

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.  With -O3 I see

 LRA hard reg assignment            :  51.99 ( 53%)     0  (  0%)
 load CSE after reload              :  17.76 ( 18%)  1584  (  0%)
 TOTAL                              :  98.76          292M

with -O2+ it's documented that we enable parts of the compiler that scale badly
with program or function size.  In particular comparing the IL with -O2 vs -O3
at RA shows:

-O2: 151276 a/t.c.329r.ira
-O3: 586385 b/t.c.329r.ira

there is -fno-expensive-optimizations that should gate the above mentioned
parts (but it does not).

On trunk the figure above adds

 reload CSE regs                    :  10.28 (  8%)    15M (  5%)

perf reports

Samples: 414K of event 'cycles:P', Event count (approx.): 450714822924
Overhead       Samples  Command  Shared Object         Symbol
  22.26%         93514  cc1      cc1                   [.] lra_assign(bool&)   
                                      ◆
  11.15%         47516  cc1      cc1                   [.]
bitmap_clear_bit(bitmap_head*, int)                        ▒
   6.89%         28977  cc1      cc1                   [.]
bitmap_set_bit(bitmap_head*, int)                          ▒
   5.07%         20477  cc1      cc1                   [.]
refs_may_alias_p_2(ao_ref*, ao_ref*, bool)                 ▒
   4.92%         20863  cc1      cc1                   [.] update_lives(int,
bool)                                    ▒
   3.81%         15434  cc1      cc1                   [.]
get_ref_base_and_extent(tree_node*, poly_int<1u, long>*, po▒
   2.77%         11215  cc1      cc1                   [.]
ao_ref_from_mem(ao_ref*, rtx_def const*)  

and lra_assign points to spill_for doing

      EXECUTE_IF_SET_IN_BITMAP (&spill_pseudos_bitmap, 0, spill_regno, bi)
        {
          if (bitmap_bit_p (&insn_conflict_pseudos, spill_regno))
            insn_pseudos_num++;
          if (spill_regno >= (unsigned int) lra_bad_spill_regno_start)
            bad_spills_num++;
          for (r = lra_reg_info[spill_regno].live_ranges;
               r != NULL;
               r = r->next)
            {
              for (p = r->start; p <= r->finish; p++)
                {
                  lra_live_range_t r2;

                  for (r2 = start_point_ranges[p];
                       r2 != NULL;
                       r2 = r2->start_next)
                    if (r2->regno >= lra_constraint_new_regno_start)
                      sparseset_set_bit (live_range_reload_inheritance_pseudos,
                                         r2->regno);

where we likely run into out-of-cache behavior after crossing some critical
working set size (and that will depend on your CPU).

Reply via email to