aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2023-03-29 11:59:16 +0200
committerRichard Biener <rguenther@suse.de>2023-03-29 13:55:47 +0200
commit86efc490ab86bfa00720479b4714da23cd7df797 (patch)
tree6c2f1d51e1efaf67f8db6ce855fe989921ccc2e5 /gcc
parentad32fcb8e91ba85cb4676c6249b6adc4b0daf9df (diff)
downloadgcc-86efc490ab86bfa00720479b4714da23cd7df797.zip
gcc-86efc490ab86bfa00720479b4714da23cd7df797.tar.gz
gcc-86efc490ab86bfa00720479b4714da23cd7df797.tar.bz2
tree-optimization/109331 - make sure to clean up the CFG after forwprop
When forwprop discovers unreachable code or makes decisions based on unreachable edges make sure to cleanup the CFG since otherwise SSA form can become invalid. PR tree-optimization/109331 * tree-ssa-forwprop.cc (pass_forwprop::execute): When we discover a taken edge make sure to cleanup the CFG. * gcc.dg/torture/pr109331.c: New testcase.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr109331.c16
-rw-r--r--gcc/tree-ssa-forwprop.cc6
2 files changed, 21 insertions, 1 deletions
diff --git a/gcc/testsuite/gcc.dg/torture/pr109331.c b/gcc/testsuite/gcc.dg/torture/pr109331.c
new file mode 100644
index 0000000..72c57b9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr109331.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+char *ustol_dpp;
+void ustol(int flags)
+{
+ char *s;
+ if (s)
+ flags |= 3;
+ switch (flags & 3)
+ case 3:
+ while (*s)
+ case '+':
+ ++s;
+ if (flags)
+ ustol_dpp = s;
+}
diff --git a/gcc/tree-ssa-forwprop.cc b/gcc/tree-ssa-forwprop.cc
index bb0fa30..9b56744 100644
--- a/gcc/tree-ssa-forwprop.cc
+++ b/gcc/tree-ssa-forwprop.cc
@@ -4046,7 +4046,11 @@ pass_forwprop::execute (function *fun)
/* Mark outgoing exectuable edges. */
if (edge e = find_taken_edge (bb, NULL))
- e->flags |= EDGE_EXECUTABLE;
+ {
+ e->flags |= EDGE_EXECUTABLE;
+ if (EDGE_COUNT (bb->succs) > 1)
+ cfg_changed = true;
+ }
else
{
FOR_EACH_EDGE (e, ei, bb->succs)