public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] tree-optimization/95679 - properly signal changes from propagate_into_phi_args
@ 2020-07-29 10:33 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2020-07-29 10:33 UTC (permalink / raw)
  To: gcc-patches

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.

Bootstrapped/tested on x86_64-unknown-linux-gnu, pushed.

Richard.

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.
---
 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.  */
-- 
2.26.2

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-07-29 10:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-29 10:33 [PATCH] tree-optimization/95679 - properly signal changes from propagate_into_phi_args Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).