[gcc(refs/users/guojiufu/heads/personal-branch)] tree-optimization/95679 - properly signal changes from propagate_into_phi_args

Jiu Fu Guo guojiufu@gcc.gnu.org
Mon Aug 10 07:26:56 GMT 2020


https://gcc.gnu.org/g:8e8792a347c87dbb82b4cf75ec3452bc5cd1d3db

commit 8e8792a347c87dbb82b4cf75ec3452bc5cd1d3db
Author: Richard Biener <rguenther@suse.de>
Date:   Wed Jul 29 09:59:01 2020 +0200

    tree-optimization/95679 - properly signal changes from propagate_into_phi_args
    
    This restores a lost setting of something_changed with the
    recent refactoring of the substitute and fold engine.  The
    reported ICE in the PR was meanwhile mitigated in other ways
    but the issue can still result in missed optimizations via
    failed runs of CFG cleanup.
    
    2020-07-29  Richard Biener  <rguenther@suse.de>
    
            PR tree-optimization/95679
            * tree-ssa-propagate.h
            (substitute_and_fold_engine::propagate_into_phi_args): Return
            whether anything changed.
            * tree-ssa-propagate.c
            (substitute_and_fold_engine::propagate_into_phi_args): Likewise.
            (substitute_and_fold_dom_walker::before_dom_children): Update
            something_changed.

Diff:
---
 gcc/tree-ssa-propagate.c | 15 +++++++++++----
 gcc/tree-ssa-propagate.h |  2 +-
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/gcc/tree-ssa-propagate.c b/gcc/tree-ssa-propagate.c
index 01ee7fd33eb..1e057284154 100644
--- a/gcc/tree-ssa-propagate.c
+++ b/gcc/tree-ssa-propagate.c
@@ -1017,11 +1017,13 @@ substitute_and_fold_dom_walker::foreach_new_stmt_in_bb
     }
 }
 
-void
+bool
 substitute_and_fold_engine::propagate_into_phi_args (basic_block bb)
 {
   edge e;
   edge_iterator ei;
+  bool propagated = false;
+
   /* Visit BB successor PHI nodes and replace PHI args.  */
   FOR_EACH_EDGE (e, ei, bb->succs)
     {
@@ -1035,11 +1037,16 @@ substitute_and_fold_engine::propagate_into_phi_args (basic_block bb)
 	      || virtual_operand_p (arg))
 	    continue;
 	  tree val = get_value (arg, phi);
-	  if (val && is_gimple_min_invariant (val)
+	  if (val
+	      && is_gimple_min_invariant (val)
 	      && may_propagate_copy (arg, val))
-	    propagate_value (use_p, val);
+	    {
+	      propagate_value (use_p, val);
+	      propagated = true;
+	    }
 	}
     }
+  return propagated;
 }
 
 edge
@@ -1229,7 +1236,7 @@ substitute_and_fold_dom_walker::before_dom_children (basic_block bb)
 	}
     }
 
-  substitute_and_fold_engine->propagate_into_phi_args (bb);
+  something_changed |= substitute_and_fold_engine->propagate_into_phi_args (bb);
 
   return NULL;
 }
diff --git a/gcc/tree-ssa-propagate.h b/gcc/tree-ssa-propagate.h
index 24de43ebc6c..9406cdf8f51 100644
--- a/gcc/tree-ssa-propagate.h
+++ b/gcc/tree-ssa-propagate.h
@@ -115,7 +115,7 @@ class substitute_and_fold_engine
   virtual void pre_fold_stmt (gimple *) { }
   virtual void post_new_stmt (gimple *) { }
 
-  void propagate_into_phi_args (basic_block);
+  bool propagate_into_phi_args (basic_block);
 
   /* Users like VRP can set this when they want to perform
      folding for every propagation.  */


More information about the Gcc-cvs mailing list