]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/106186 - propagate out virtual LC PHI nodes properly
authorRichard Biener <rguenther@suse.de>
Tue, 5 Jul 2022 09:38:52 +0000 (11:38 +0200)
committerRichard Biener <rguenther@suse.de>
Tue, 5 Jul 2022 12:11:51 +0000 (14:11 +0200)
The code to remove LC PHI nodes in clean_up_loop_closed_phi does not handle
virtual operands because may_propagate_copy generally returns false
for them.  The following copies the merge_blocks variant for
dealing with them.

This fixes a missed jump threading in gcc.dg/auto-init-uninit-4.c
which manifests in bogus uninit diagnostics.

PR tree-optimization/106186
* tree-ssa-propagate.cc (clean_up_loop_closed_phi):
Properly handle virtual PHI nodes.

gcc/tree-ssa-propagate.cc

index 163b24f0e6930a0489c18869f2ef95de684afa24..9dc4bfd85bf514574a357a692f09e3606aefa12c 100644 (file)
@@ -1272,7 +1272,21 @@ clean_up_loop_closed_phi (function *fun)
              rhs = gimple_phi_arg_def (phi, 0);
              lhs = gimple_phi_result (phi);
 
-             if (rhs && may_propagate_copy (lhs, rhs))
+             if (virtual_operand_p (rhs))
+               {
+                 imm_use_iterator iter;
+                 use_operand_p use_p;
+                 gimple *stmt;
+
+                 FOR_EACH_IMM_USE_STMT (stmt, iter, lhs)
+                   FOR_EACH_IMM_USE_ON_STMT (use_p, iter)
+                     SET_USE (use_p, rhs);
+
+                 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (lhs))
+                   SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rhs) = 1;
+                 remove_phi_node (&gsi, true);
+               }
+             else if (may_propagate_copy (lhs, rhs))
                {
                  /* Dump details.  */
                  if (dump_file && (dump_flags & TDF_DETAILS))