aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2022-07-05 11:38:52 +0200
committerRichard Biener <rguenther@suse.de>2022-07-05 14:11:51 +0200
commitc3d2600cfb476e576fd27f3f29f49e968e86774d (patch)
tree628cabfcc381f5391a4feca01a243160c50a0897
parent1a6e0d8252a71c61d4dc616044fb25b5ac2cfffb (diff)
downloadgcc-c3d2600cfb476e576fd27f3f29f49e968e86774d.zip
gcc-c3d2600cfb476e576fd27f3f29f49e968e86774d.tar.gz
gcc-c3d2600cfb476e576fd27f3f29f49e968e86774d.tar.bz2
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.
-rw-r--r--gcc/tree-ssa-propagate.cc16
1 files changed, 15 insertions, 1 deletions
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 @@ 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))