]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/95679 - properly signal changes from propagate_into_phi_args
authorRichard Biener <rguenther@suse.de>
Wed, 29 Jul 2020 07:59:01 +0000 (09:59 +0200)
committerRichard Biener <rguenther@suse.de>
Wed, 29 Jul 2020 10:34:29 +0000 (12:34 +0200)
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.

gcc/tree-ssa-propagate.c
gcc/tree-ssa-propagate.h

index 01ee7fd33eb19c5308cec043ace91a0dd59a1e6b..1e05728415437d6ddb5e3189cb1fa2b1f4a2cbb4 100644 (file)
@@ -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;
 }
index 24de43ebc6c6b074a34d095f8dc68cd02cac214f..9406cdf8f515da98ec5427d9d96b567e1cf77d87 100644 (file)
@@ -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.  */