tree-optimization/106186 - propagate out virtual LC PHI nodes properly
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.
diff --git a/gcc/tree-ssa-propagate.cc b/gcc/tree-ssa-propagate.cc
index 163b24f..9dc4bfd 100644
--- a/gcc/tree-ssa-propagate.cc
+++ b/gcc/tree-ssa-propagate.cc
@@ -1272,7 +1272,21 @@
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))