From: Richard Biener Date: Tue, 5 Jul 2022 09:38:52 +0000 (+0200) Subject: tree-optimization/106186 - propagate out virtual LC PHI nodes properly X-Git-Tag: basepoints/gcc-14~5704 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c3d2600cfb476e576fd27f3f29f49e968e86774d;p=thirdparty%2Fgcc.git 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 163b24f0e69..9dc4bfd85bf 100644 --- a/gcc/tree-ssa-propagate.cc +++ b/gcc/tree-ssa-propagate.cc @@ -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))