cleanup_control_expr_graph when setting EDGE_FALLTHRU cleared all
existing edge flags such as EDGE_IRREDUCIBLE_LOOP rather than
just the no longer relevant EDGE_TRUE_VALUE and EDGE_FALSE_VALUE flags.
Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed to trunk.
Richard.
PR middle-end/125156
* tree-cfgcleanup.cc (cleanup_control_expr_graph): Clear
EDGE_TRUE_VALUE and EDGE_FALSE_VALUE edge flags only.
* gcc.dg/torture/pr125156.c: New testcase.
---
gcc/testsuite/gcc.dg/torture/pr125156.c | 26 +++++++++++++++++++++++++
gcc/tree-cfgcleanup.cc | 3 ++-
2 files changed, 28 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/gcc.dg/torture/pr125156.c
diff --git a/gcc/testsuite/gcc.dg/torture/pr125156.c
b/gcc/testsuite/gcc.dg/torture/pr125156.c
new file mode 100644
index 00000000000..bb232b1a436
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr125156.c
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+int64_t g1, g8;
+
+void g14()
+{
+ int16_t v5;
+ goto lbl_cont30;
+lbl_bf2:
+ g8 = 0;
+lbl_b5:
+ g1 = g1 - 8366249724514421075;
+ switch (v5)
+case 5:
+case 2:
+ goto lbl_b5;
+ goto lbl_bf2;
+lbl_cont30:
+ switch (v5)
+ {
+ case 0: goto lbl_bf2;
+ case 5: goto lbl_b5;
+ }
+}
diff --git a/gcc/tree-cfgcleanup.cc b/gcc/tree-cfgcleanup.cc
index 234b45a219f..85b9a3cedaa 100644
--- a/gcc/tree-cfgcleanup.cc
+++ b/gcc/tree-cfgcleanup.cc
@@ -240,7 +240,8 @@ cleanup_control_expr_graph (basic_block bb,
gimple_stmt_iterator gsi)
bitmap_set_bit (cfgcleanup_altered_bbs, bb->index);
gsi_remove (&gsi, true);
- taken_edge->flags = EDGE_FALLTHRU;
+ taken_edge->flags &= ~(EDGE_TRUE_VALUE|EDGE_FALSE_VALUE);
+ taken_edge->flags |= EDGE_FALLTHRU;
return retval;
}
--
2.51.0