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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |wschmidt at gcc dot gnu.org

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
It's SLSR, so a workaround is -fno-tree-slsr.

It's a bit iffy to fix given one of the suitable points to fence off is
alloc_cand_and_find_basis where we should "reject"
SSA_NAME_OCCURS_IN_ABNORMAL_PHI (base) but this function isn't supposed
to "FAIL".

I'm also not sure it covers the cases fully.

Basically when doing replacements SLSR may _never_ end up with
a SSA_NAME_OCCURS_IN_ABNORMAL_PHI SSA name in the replacement expression.

Costing doesn't seem to apply to unconditional candidates so fending it
off there doesn't seem viable.

The easiest thing is to try fend off during the stmt walk like with the
following big hammer.  Not sure if that's enough or we walk SSA def
stmts from other places.  Bill, can you take over with the hint below?

Index: gcc/gimple-ssa-strength-reduction.c
===================================================================
--- gcc/gimple-ssa-strength-reduction.c (revision 253203)
+++ gcc/gimple-ssa-strength-reduction.c (working copy)
@@ -802,6 +802,8 @@ slsr_process_phi (gphi *phi, bool speed)
      definitions must be in the same position in the loop hierarchy
      as PHI.  */

+  if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (gimple_phi_result (phi)))
+    return;
   for (i = 0; i < gimple_phi_num_args (phi); i++)
     {
       slsr_cand_t arg_cand;
@@ -810,7 +812,8 @@ slsr_process_phi (gphi *phi, bool speed)
       gimple *arg_stmt = NULL;
       basic_block arg_bb = NULL;

-      if (TREE_CODE (arg) != SSA_NAME)
+      if (TREE_CODE (arg) != SSA_NAME
+         || SSA_NAME_OCCURS_IN_ABNORMAL_PHI (arg))
        return;

       arg_cand = base_cand_from_table (arg);
@@ -1738,6 +1741,18 @@ find_candidates_dom_walker::before_dom_c
     {
       gimple *gs = gsi_stmt (gsi);

+      tree op;
+      ssa_op_iter iter;
+      bool abnormal_found = false;
+      FOR_EACH_SSA_TREE_OPERAND (op, gs, iter, SSA_OP_USE|SSA_OP_DEF)
+       if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (op))
+         {
+           abnormal_found = true;
+           break;
+         }
+      if (abnormal_found)
+       continue;
+
       if (gimple_vuse (gs) && gimple_assign_single_p (gs))
        slsr_process_ref (gs);

Reply via email to