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

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

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

--- Comment #5 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-02-16 
12:41:30 UTC ---
Proposed patch:

Index: gcc/tree-ssa-loop-ivopts.c
===================================================================
--- gcc/tree-ssa-loop-ivopts.c  (revision 184304)
+++ gcc/tree-ssa-loop-ivopts.c  (working copy)
@@ -2506,6 +2506,15 @@ add_iv_value_candidates (struct ivopts_d
   if (offset
       || base != iv->base)
     add_candidate (data, base, iv->step, false, use);
+
+  /* Fourth, try removing the base-object for pointer IVs.  */
+  if (TREE_CODE (iv->base) == POINTER_PLUS_EXPR)
+    {
+      tree base_object = iv->base_object;
+      STRIP_NOPS (base_object);
+      if (operand_equal_p (TREE_OPERAND (iv->base, 0), base_object, 0))
+       add_candidate (data, TREE_OPERAND (iv->base, 1), iv->step, false, use);
+    }
 }

 /* Adds candidates based on the uses.  */
@@ -4062,7 +4071,13 @@ get_computation_cost_at (struct ivopts_d
       if (use->iv->base_object
          && cand->iv->base_object
          && !operand_equal_p (use->iv->base_object, cand->iv->base_object, 0))
-       return infinite_cost;
+       {
+         if (dump_file && (dump_flags & TDF_DETAILS))
+           fprintf (dump_file, "Not considering candidate %d for use %d "
+                    "because they have different pointer bases%s\n",
+                    cand->id, use->id, address_p ? "(address_p)" : "");
+         return infinite_cost;
+       }
     }

   if (TYPE_PRECISION (utype) < TYPE_PRECISION (ctype))

Reply via email to