aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/gimple-loop-jam.cc10
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr106521.c17
2 files changed, 26 insertions, 1 deletions
diff --git a/gcc/gimple-loop-jam.cc b/gcc/gimple-loop-jam.cc
index 8cde6c7..a8a57d3 100644
--- a/gcc/gimple-loop-jam.cc
+++ b/gcc/gimple-loop-jam.cc
@@ -39,6 +39,7 @@ along with GCC; see the file COPYING3. If not see
#include "tree-ssa-loop-ivopts.h"
#include "tree-vectorizer.h"
#include "tree-ssa-sccvn.h"
+#include "tree-cfgcleanup.h"
/* Unroll and Jam transformation
@@ -609,9 +610,16 @@ tree_loop_unroll_and_jam (void)
if (todo)
{
+ free_dominance_info (CDI_DOMINATORS);
+ /* We need to cleanup the CFG first since otherwise SSA form can
+ be not up-to-date from the VN run. */
+ if (todo & TODO_cleanup_cfg)
+ {
+ cleanup_tree_cfg ();
+ todo &= ~TODO_cleanup_cfg;
+ }
rewrite_into_loop_closed_ssa (NULL, 0);
scev_reset ();
- free_dominance_info (CDI_DOMINATORS);
}
return todo;
}
diff --git a/gcc/testsuite/gcc.dg/torture/pr106521.c b/gcc/testsuite/gcc.dg/torture/pr106521.c
new file mode 100644
index 0000000..05c8ce5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr106521.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-floop-unroll-and-jam --param unroll-jam-min-percent=0" } */
+
+short a, b, e;
+volatile long c;
+long d;
+int main() {
+ for (; d; d++) {
+ long g = a = 1;
+ for (; a; a++) {
+ g++;
+ c;
+ }
+ g && (b = e);
+ }
+ return 0;
+}