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

Bill Schmidt <wschmidt at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|                            |x86_64-pc-linux-gnu

--- Comment #5 from Bill Schmidt <wschmidt at gcc dot gnu.org> ---
OK, thanks.  While I get a cross built, could you please try the following
patch?

Index: gcc/gimple-ssa-strength-reduction.c                                      
===================================================================
--- gcc/gimple-ssa-strength-reduction.c (revision 240946)                       
+++ gcc/gimple-ssa-strength-reduction.c (working copy)                          
@@ -3367,7 +3367,7 @@ replace_one_candidate (slsr_cand_t c, unsigned i,
     {                                                                          
       tree stride_type = TREE_TYPE (c->stride);                                
       tree orig_type = TREE_TYPE (orig_rhs2);                                  
-      gcc_assert (repl_code != POINTER_PLUS_EXPR);                             
+      tree basis_type = TREE_TYPE (basis_name);                                

       if (types_compatible_p (orig_type, stride_type))                         
        rhs2 = c->stride;                                                       
@@ -3374,7 +3374,16 @@ replace_one_candidate (slsr_cand_t c, unsigned i,
       else                                                                     
        rhs2 = introduce_cast_before_cand (c, orig_type, c->stride);            

-      if (orig_code != MINUS_EXPR                                              
+      if (POINTER_TYPE_P (basis_type))                                         
+       {                                                                       
+         tree neg_stride = fold_unary (NEGATE_EXPR, sizetype, rhs2);           
+         gimple_stmt_iterator gsi = gsi_for_stmt (c->cand_stmt);               
+         gimple_assign_set_rhs_with_ops (&gsi, POINTER_PLUS_EXPR,              
+                                         basis_name, neg_stride);              
+         update_stmt (gsi_stmt (gsi));                                         
+         c->cand_stmt = gsi_stmt (gsi);                                        
+       }                                                                       
+      else if (orig_code != MINUS_EXPR                                         
          || !operand_equal_p (basis_name, orig_rhs1, 0)                        
          || !operand_equal_p (rhs2, orig_rhs2, 0))                             
        {

Reply via email to