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

Kewen Lin <linkw at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=88652

--- Comment #3 from Kewen Lin <linkw at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #1)
> Maybe https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84842#c17 patch helps

Unfortunately it doesn't help, I noticed this and tried below:

diff --git a/gcc/sel-sched.cc b/gcc/sel-sched.cc
index a35b5e16c91..8e3b3bb0467 100644
--- a/gcc/sel-sched.cc
+++ b/gcc/sel-sched.cc
@@ -323,6 +323,10 @@ struct reg_rename

   /* The set of ABIs used by calls that the code motion path crosses.  */
   unsigned int crossed_call_abis : NUM_ABI_IDS;
+
+  /* True if we have merged expressions and one of them had availability
+     bit set.  */
+  unsigned int merged_available_expr : 1;
 };

 /* A global structure that contains the needed information about harg
@@ -388,6 +392,10 @@ struct fur_static_params

   /* The set of ABIs used by calls that the code motion path crosses.  */
   unsigned int crossed_call_abis : NUM_ABI_IDS;
+
+  /* True if we have merged expressions and one of them had availability
+     bit set.  */
+  unsigned int merged_available_expr : 1;
 };

 typedef struct fur_static_params *fur_static_params_p;
@@ -1554,7 +1562,8 @@ verify_target_availability (expr_t expr, regset
used_regs,
                || !hard_available
                || (!reload_completed
                    && reg_rename_p->crossed_call_abis
-                   && REG_N_CALLS_CROSSED (regno) == 0));
+                   && REG_N_CALLS_CROSSED (regno) == 0)
+               || reg_rename_p->merged_available_expr);
 }

 /* Collect unavailable registers due to liveness for EXPR from BNDS
@@ -1654,6 +1663,8 @@ find_best_reg_for_expr (expr_t expr, blist_t bnds, bool
*is_orig_reg_p)
   used_regs = get_clear_regset_from_pool ();
   CLEAR_HARD_REG_SET (reg_rename_data.unavailable_hard_regs);

+  reg_rename_data.crossed_call_abis = false;
+  reg_rename_data.merged_available_expr = false;
   collect_unavailable_regs_from_bnds (expr, bnds, used_regs, &reg_rename_data,
                                      &original_insns);

@@ -1861,7 +1872,7 @@ identical_copy_p (rtx_insn *insn)
 /* Undo all transformations on *AV_PTR that were done when
    moving through INSN.  */
 static void
-undo_transformations (av_set_t *av_ptr, rtx_insn *insn)
+undo_transformations (av_set_t *av_ptr, rtx_insn *insn, void *static_params)
 {
   av_set_iterator av_iter;
   expr_t expr;
@@ -1940,6 +1951,8 @@ undo_transformations (av_set_t *av_ptr, rtx_insn *insn)
                      copy, which was in turn substituted.  The history is
wrong
                      in this case.  Do it the hard way.  */
                   add = substitute_reg_in_expr (tmp_expr, insn, true);
+                if (code_motion_path_driver_info == &fur_hooks)
+                  ((fur_static_params_p) static_params)->merged_available_expr
= true;
                 if (add)
                   av_set_add (&new_set, tmp_expr);
                 clear_expr (tmp_expr);
@@ -3273,6 +3286,7 @@ find_used_regs (insn_t insn, av_set_t orig_ops, regset
used_regs,
   sparams.crossed_call_abis = 0;
   sparams.original_insns = original_insns;
   sparams.used_regs = used_regs;
+  sparams.merged_available_expr = false;

   /* Set the appropriate hooks and data.  */
   code_motion_path_driver_info = &fur_hooks;
@@ -3280,6 +3294,7 @@ find_used_regs (insn_t insn, av_set_t orig_ops, regset
used_regs,
   res = code_motion_path_driver (insn, orig_ops, NULL, &lparams, &sparams);

   reg_rename_p->crossed_call_abis |= sparams.crossed_call_abis;
+  reg_rename_p->merged_available_expr |= sparams.merged_available_expr;

   gcc_assert (res == 1);
   gcc_assert (original_insns && *original_insns);
@@ -6570,7 +6585,7 @@ code_motion_path_driver (insn_t insn, av_set_t orig_ops,
ilist_t path,
            {
              /* Av set ops could have been changed when moving through this
                 insn.  To find them below it, we have to un-substitute them. 
*/
-             undo_transformations (&orig_ops, insn);
+             undo_transformations (&orig_ops, insn, static_params);
            }
          else
            {

Reply via email to