http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54693



--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-10-19 
13:49:03 UTC ---

What I had in mind for ivopts is roughly this.  Not sure about the last

argument to get_computation_at.  For normal statements I'd hope it shouldn't

make a difference, the stmt that initializes the unused iv should hopefully not

be in any way related to the place where increment of the new iv will happen,

for phis it needs more investigation.



And I don't see any infrastructure to gimplify a larger expression into several

debug temporaries with simpler expressions.



--- gcc/tree-ssa-loop-ivopts.c.jj    2012-09-12 10:57:02.629762526 +0200

+++ gcc/tree-ssa-loop-ivopts.c    2012-10-19 15:35:19.631230006 +0200

@@ -6422,7 +6422,76 @@ remove_unused_ivs (struct ivopts_data *d

       && !info->inv_id

       && !info->iv->have_use_for

       && !info->preserve_biv)

-    bitmap_set_bit (toremove, SSA_NAME_VERSION (info->iv->ssa_name));

+    {

+      bitmap_set_bit (toremove, SSA_NAME_VERSION (info->iv->ssa_name));

+

+      if (MAY_HAVE_DEBUG_STMTS

+          && SSA_NAME_DEF_STMT (info->iv->ssa_name))

+        {

+          tree comp = NULL_TREE;

+          imm_use_iterator imm_iter;

+          use_operand_p use_p;

+          gimple stmt;

+

+          FOR_EACH_IMM_USE_STMT (stmt, imm_iter, info->iv->ssa_name)

+        {

+          if (!gimple_debug_bind_p (stmt))

+            continue;

+

+          if (comp == NULL_TREE)

+            {

+              struct iv_use dummy_use;

+              struct iv_cand *best_cand = NULL, *cand;

+              unsigned i, best_pref = 0, cand_pref;

+

+              memset (&dummy_use, 0, sizeof (dummy_use));

+              dummy_use.iv = info->iv;

+              for (i = 0; i < n_iv_uses (data) && i < 64; i++)

+            {

+              cand = iv_use (data, i)->selected;

+              if (cand == best_cand)

+                continue;

+              cand_pref = operand_equal_p (cand->iv->step,

+                               info->iv->step, 0)

+                      ? 4 : 0;

+              cand_pref

+                += TYPE_MODE (TREE_TYPE (cand->iv->base))

+                   == TYPE_MODE (TREE_TYPE (info->iv->base))

+                   ? 2 : 0;

+              cand_pref

+                += TREE_CODE (cand->iv->base) == INTEGER_CST

+                   ? 1 : 0;

+              if (best_cand == NULL || best_pref < cand_pref)

+                {

+                  best_cand = cand;

+                  best_pref = cand_pref;

+                }

+            }

+              if (best_cand == NULL)

+            BREAK_FROM_IMM_USE_STMT (imm_iter);

+

+              comp = get_computation_at (data->current_loop,

+                         &dummy_use, best_cand,

+                         SSA_NAME_DEF_STMT (info->iv->ssa_name));

+              if (comp == NULL_TREE)

+            BREAK_FROM_IMM_USE_STMT (imm_iter);

+              /* "gimplify" into DEBUG temporaries expression comp,

+             insert immediately after

+             SSA_NAME_DEF_STMT (info->iv->ssa_name).

+             Set comp to the final DEBUG_EXPR_DECL.  */

+#if 1

+              (void) comp;

+              BREAK_FROM_IMM_USE_STMT (imm_iter);

+#endif

+            }

+

+          FOR_EACH_IMM_USE_ON_STMT (use_p, imm_iter)

+            SET_USE (use_p, comp);

+

+          update_stmt (stmt);

+        }

+        }

+    }

     }



   release_defs_bitset (toremove);

Reply via email to