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

--- Comment #2 from Andreas Krebbel <krebbel at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #1)
...
> Would be interesting to know the sparseness of regs / BBs for your testcase
> at the point of LRA and whether compacting regs (do we ever do that?) might
> be a good idea in general.  (we do compact BBs regularly)

Good point. Only 9352 of the 27089 pseudos appear to be actually referenced.
Hence the following patch fixes the problem for me:

diff --git a/gcc/ira.c b/gcc/ira.c
index c8f2df43dd1..965819e1ef9 100644
--- a/gcc/ira.c
+++ b/gcc/ira.c
@@ -5157,6 +5157,7 @@ ira (FILE *f)
   int ira_max_point_before_emit;
   bool saved_flag_caller_saves = flag_caller_saves;
   enum ira_region saved_flag_ira_region = flag_ira_region;
+  int i, num_used_regs = 0;

   clear_bb_flags ();

@@ -5172,12 +5173,17 @@ ira (FILE *f)

   ira_conflicts_p = optimize > 0;

+  /* Determine the number of pseudos actually requiring coloring.  */
+  for (i = FIRST_PSEUDO_REGISTER; i < max_reg_num (); i++)
+    num_used_regs += !!(DF_REG_USE_COUNT (i) + DF_REG_DEF_COUNT (i));
+
   /* If there are too many pseudos and/or basic blocks (e.g. 10K
      pseudos and 10K blocks or 100K pseudos and 1K blocks), we will
      use simplified and faster algorithms in LRA.  */
   lra_simple_p
     = (ira_use_lra_p
-       && max_reg_num () >= (1 << 26) / last_basic_block_for_fn (cfun));
+       && num_used_regs >= (1 << 26) / last_basic_block_for_fn (cfun));
+
   if (lra_simple_p)
     {
       /* It permits to skip live range splitting in LRA.  */

Reply via email to