aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Pinski <quic_apinski@quicinc.com>2024-04-28 20:21:02 -0700
committerAndrew Pinski <quic_apinski@quicinc.com>2024-04-30 09:11:55 -0700
commita30d2e6bd0b965e7687f58530a767a3c3b079158 (patch)
tree526b9e2f4da08b9b37631449c7fdc46673e5a7fb
parent611815e0233302e1fcccca113e6f865fa450b7ae (diff)
PHIOPT: Value-replacement check undef
While moving value replacement part of PHIOPT over to use match-and-simplify, I ran into the case where we would have an undef use that was conditional become unconditional. This prevents that. I can't remember at this point what the testcase was though. Bootstrapped and tested on x86_64-linux-gnu with no regressions. gcc/ChangeLog: * tree-ssa-phiopt.cc (value_replacement): Reject undef variables so they don't become unconditional used. Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
-rw-r--r--gcc/tree-ssa-phiopt.cc7
1 files changed, 7 insertions, 0 deletions
diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc
index a2bdcb5eae8..f166c3132cb 100644
--- a/gcc/tree-ssa-phiopt.cc
+++ b/gcc/tree-ssa-phiopt.cc
@@ -1146,6 +1146,13 @@ value_replacement (basic_block cond_bb, basic_block middle_bb,
if (code != NE_EXPR && code != EQ_EXPR)
return 0;
+ /* Do not make conditional undefs unconditional. */
+ if ((TREE_CODE (arg0) == SSA_NAME
+ && ssa_name_maybe_undef_p (arg0))
+ || (TREE_CODE (arg1) == SSA_NAME
+ && ssa_name_maybe_undef_p (arg1)))
+ return false;
+
/* If the type says honor signed zeros we cannot do this
optimization. */
if (HONOR_SIGNED_ZEROS (arg1))