Hi,

The previous fix for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77916
ensured that record_increment would use normal multiplier initializers
for increments of -1 with unknown strides, just as for all other negative
increments.  However, we still had a problem in insert_initializers wherein
the test for whether the replacement will need a POINTER_PLUS_EXPR was not
accurate.  This patch fixes this, and again removes the stopgap solution
so that we can process -1 increments with pointer types.

Markus Trippelsdorf kindly tested all of the ffmpeg code on x86_64 with
-march=amdfam10 to ensure there are no more of these issues lurking there.
That has been a fertile environment for these kinds of negative pointer
increments.

Bootstrapped and tested on powerpc64le-unknown-linux-gnu with no new
regressions, committed.

Thanks,
Bill


2016-10-19  Bill Schmidt  <wschm...@linux.vnet.ibm.com>

        PR tree-optimization/77916
        PR tree-optimization/77937
        * gimple-ssa-strength-reduction.c (analyze_increments): Remove
        stopgap fix.
        (insert_initializers): Requirement of initializer for -1 should be
        based on pointer-typedness of the candidate basis.


Index: gcc/gimple-ssa-strength-reduction.c
===================================================================
--- gcc/gimple-ssa-strength-reduction.c (revision 241305)
+++ gcc/gimple-ssa-strength-reduction.c (working copy)
@@ -2825,10 +2825,6 @@ analyze_increments (slsr_cand_t first_dep, machine
                   && !POINTER_TYPE_P (first_dep->cand_type)))
        incr_vec[i].cost = COST_NEUTRAL;
 
-      /* FIXME: Still having trouble with pointers with a -1 increment.  */
-      else if (incr == -1 && POINTER_TYPE_P (first_dep->cand_type))
-       incr_vec[i].cost = COST_INFINITE;
-
       /* FORNOW: If we need to add an initializer, give up if a cast from
         the candidate's type to its stride's type can lose precision.
         This could eventually be handled better by expressly retaining the
@@ -3115,7 +3111,7 @@ insert_initializers (slsr_cand_t c)
       if (!profitable_increment_p (i)
          || incr == 1
          || (incr == -1
-             && gimple_assign_rhs_code (c->cand_stmt) != POINTER_PLUS_EXPR)
+             && (!POINTER_TYPE_P (lookup_cand (c->basis)->cand_type)))
          || incr == 0)
        continue;
 

Reply via email to