Hi,

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77824 reports unreachable code 
where MODIFY_EXPR
is being tested instead of SSA_NAME to identify RHS's for copies.  This patch 
corrects that.
I instrumented the compiler to identify copies being added to the candidate 
table, and found
that this now occurs frequently in GCC's support libraries as well as 
throughout SPEC CPU2006.
I spot-checked the SLSR dumps for a number of code examples and found that, 
while copies often
now appear in the candidate table, and sometimes appear in candidate chains 
representing 
potential opportunities, I have not yet found a place where this changes code 
generation.

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

Thanks,

Bill



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

        PR tree-optimization/77824
        * gimple-ssa-strength-reduction.c (stmt_cost): Explicitly return
        zero cost for copies.
        (find_candidates_dom_walker::before_dom_children): Replace
        MODIFY_EXPR with SSA_NAME.
        (replace_mult_candidate): Likewise.
        (replace_profitable_candidates): Likewise.


Index: gcc/gimple-ssa-strength-reduction.c
===================================================================
--- gcc/gimple-ssa-strength-reduction.c (revision 240924)
+++ gcc/gimple-ssa-strength-reduction.c (working copy)
@@ -688,6 +688,9 @@ stmt_cost (gimple *gs, bool speed)
 
     /* Note that we don't assign costs to copies that in most cases
        will go away.  */
+    case SSA_NAME:
+      return 0;
+      
     default:
       ;
     }
@@ -1693,7 +1696,7 @@ find_candidates_dom_walker::before_dom_children (b
              gcc_fallthrough ();
 
            CASE_CONVERT:
-           case MODIFY_EXPR:
+           case SSA_NAME:
            case NEGATE_EXPR:
              rhs1 = gimple_assign_rhs1 (gs);
              if (TREE_CODE (rhs1) != SSA_NAME)
@@ -1724,7 +1727,7 @@ find_candidates_dom_walker::before_dom_children (b
              slsr_process_cast (gs, rhs1, speed);
              break;
 
-           case MODIFY_EXPR:
+           case SSA_NAME:
              slsr_process_copy (gs, rhs1, speed);
              break;
 
@@ -2010,7 +2013,7 @@ replace_mult_candidate (slsr_cand_t c, tree basis_
       && bump.to_shwi () != HOST_WIDE_INT_MIN
       /* It is not useful to replace casts, copies, or adds of
         an SSA name and a constant.  */
-      && cand_code != MODIFY_EXPR
+      && cand_code != SSA_NAME
       && !CONVERT_EXPR_CODE_P (cand_code)
       && cand_code != PLUS_EXPR
       && cand_code != POINTER_PLUS_EXPR
@@ -3445,7 +3448,7 @@ replace_profitable_candidates (slsr_cand_t c)
         to a cast or copy.  */
       if (i >= 0
          && profitable_increment_p (i) 
-         && orig_code != MODIFY_EXPR
+         && orig_code != SSA_NAME
          && !CONVERT_EXPR_CODE_P (orig_code))
        {
          if (phi_dependent_cand_p (c))

Reply via email to