aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-phiopt.cc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2023-07-04 12:52:27 +0200
committerRichard Biener <rguenther@suse.de>2023-07-04 14:13:33 +0200
commit819285ef10a87d663f8c181c06aa88d1d9f75aed (patch)
tree362a9bf09cf73b7063c2136ad1d58cd8b3725f56 /gcc/tree-ssa-phiopt.cc
parent86ff0533fcb442be17942eef16f8b8db466c4fd4 (diff)
downloadgcc-819285ef10a87d663f8c181c06aa88d1d9f75aed.zip
gcc-819285ef10a87d663f8c181c06aa88d1d9f75aed.tar.gz
gcc-819285ef10a87d663f8c181c06aa88d1d9f75aed.tar.bz2
tree-optimization/110491 - PHI-OPT and undefs
The following makes sure to not make conditional undefs in PHI arguments unconditional by folding cond ? arg1 : arg2. PR tree-optimization/110491 * tree-ssa-phiopt.cc (match_simplify_replacement): Check whether the PHI args are possibly undefined before folding the COND_EXPR. * gcc.dg/torture/pr110491.c: New testcase.
Diffstat (limited to 'gcc/tree-ssa-phiopt.cc')
-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 31a7c39..467c9fd 100644
--- a/gcc/tree-ssa-phiopt.cc
+++ b/gcc/tree-ssa-phiopt.cc
@@ -785,6 +785,13 @@ match_simplify_replacement (basic_block cond_bb, basic_block middle_bb,
arg_false = arg0;
}
+ /* Do not make conditional undefs unconditional. */
+ if ((TREE_CODE (arg_true) == SSA_NAME
+ && ssa_name_maybe_undef_p (arg_true))
+ || (TREE_CODE (arg_false) == SSA_NAME
+ && ssa_name_maybe_undef_p (arg_false)))
+ return false;
+
tree type = TREE_TYPE (gimple_phi_result (phi));
result = gimple_simplify_phiopt (early_p, type, stmt,
arg_true, arg_false,