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

--- Comment #6 from H.J. Lu <hjl.tools at gmail dot com> ---
When the same register is assigned by assign_by_spills which sets
reg_renumber and assigned by assign_spill_hard_regs which sets
hard_regs_spilled_into, lra_create_live_ranges_1 treats the register
only for spill, not for assignment.  Should lra_create_live_ranges_1
be updated to check for reg_renumber?


diff --git a/gcc/lra-lives.c b/gcc/lra-lives.c
index 1d1525ca2e5..cb5a482805e 100644
--- a/gcc/lra-lives.c
+++ b/gcc/lra-lives.c
@@ -1305,6 +1305,7 @@ lra_create_live_ranges_1 (bool all_p, bool dead_insn_p)
   int i, hard_regno, max_regno = max_reg_num ();
   int curr_point;
   bool bb_live_change_p, have_referenced_pseudos = false;
+  HARD_REG_SET lra_assigned_reg_set;

   timevar_push (TV_LRA_CREATE_LIVE_RANGES);

@@ -1314,6 +1315,7 @@ lra_create_live_ranges_1 (bool all_p, bool dead_insn_p)
        "\n********** Pseudo live ranges #%d: **********\n\n",
        ++lra_live_range_iter);
   memset (lra_hard_reg_usage, 0, sizeof (lra_hard_reg_usage));
+  CLEAR_HARD_REG_SET (lra_assigned_reg_set);
   for (i = 0; i < max_regno; i++)
     {
       lra_reg_info[i].live_ranges = NULL;
@@ -1337,7 +1339,10 @@ lra_create_live_ranges_1 (bool all_p, bool dead_insn_p)
     && lra_reg_info[i].nrefs != 0)
   {
     if ((hard_regno = reg_renumber[i]) >= 0)
-      lra_hard_reg_usage[hard_regno] += lra_reg_info[i].freq;
+      {
+        lra_hard_reg_usage[hard_regno] += lra_reg_info[i].freq;
+        SET_HARD_REG_BIT (lra_assigned_reg_set, hard_regno);
+      }
     have_referenced_pseudos = true;
   }
     }
@@ -1392,7 +1397,8 @@ lra_create_live_ranges_1 (bool all_p, bool dead_insn_p)
    DF-infrastructure solver to solve live data flow problem.  */
       for (int i = 0; HARD_REGISTER_NUM_P (i); ++i)
   {
-    if (TEST_HARD_REG_BIT (hard_regs_spilled_into, i))
+    if (TEST_HARD_REG_BIT (hard_regs_spilled_into, i)
+        && !TEST_HARD_REG_BIT (lra_assigned_reg_set, i))
       bitmap_clear_bit (&all_hard_regs_bitmap, i);
   }
       df_simple_dataflow

Reply via email to