]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PHIOPT: Value-replacement check undef
authorAndrew Pinski <quic_apinski@quicinc.com>
Mon, 29 Apr 2024 03:21:02 +0000 (20:21 -0700)
committerAndrew Pinski <quic_apinski@quicinc.com>
Tue, 30 Apr 2024 16:11:55 +0000 (09:11 -0700)
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>
gcc/tree-ssa-phiopt.cc

index a2bdcb5eae81d43054a5fd833c6ba11ba9ebb27f..f166c3132cb7e6e2a382ed4aef0893f98739b267 100644 (file)
@@ -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))