Hi,
this patch fixes PR70045, a graphite 6 regression.
The problem is as follows: in graphite_create_new_loop_guard, a
condition cond_expr is constructed using an upper bound expression *ub.
During the call:
...
exit_edge = create_empty_if_region_on_edge (entry_edge, cond_expr);
...
the cond_expr is modified in place, which has as side-effect that *ub is
modified.
The patch fixes this by unsharing the cond_expr before passing it as
argument to create_empty_if_region_on_edge.
Bootstrapped and reg-tested on x86_64.
OK for stage4 trunk?
Thanks,
- Tom
Unshare create_empty_if_region_on_edge argument
2016-03-11 Tom de Vries <t...@codesourcery.com>
PR tree-optimization/70045
* graphite-isl-ast-to-gimple.c (graphite_create_new_loop_guard): Unshare
create_empty_if_region_on_edge argument.
* gcc.dg/graphite/pr70045.c: New test.
---
gcc/graphite-isl-ast-to-gimple.c | 3 ++-
gcc/testsuite/gcc.dg/graphite/pr70045.c | 28 ++++++++++++++++++++++++++++
2 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/gcc/graphite-isl-ast-to-gimple.c b/gcc/graphite-isl-ast-to-gimple.c
index 89a4118..8dd5dc8 100644
--- a/gcc/graphite-isl-ast-to-gimple.c
+++ b/gcc/graphite-isl-ast-to-gimple.c
@@ -821,7 +821,8 @@ graphite_create_new_loop_guard (edge entry_edge,
if (integer_onep (cond_expr))
exit_edge = entry_edge;
else
- exit_edge = create_empty_if_region_on_edge (entry_edge, cond_expr);
+ exit_edge = create_empty_if_region_on_edge (entry_edge,
+ unshare_expr (cond_expr));
return exit_edge;
}
diff --git a/gcc/testsuite/gcc.dg/graphite/pr70045.c b/gcc/testsuite/gcc.dg/graphite/pr70045.c
new file mode 100644
index 0000000..9f98b1f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/graphite/pr70045.c
@@ -0,0 +1,28 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -floop-interchange" } */
+
+int a, b, d, e, f;
+int c[9];
+void
+fn1 ()
+{
+ e = 1;
+ for (; e >= 0; e--)
+ {
+ d = 1;
+ for (; d >= 0; d--)
+ {
+ f = 0;
+ for (; f <= 1; f++)
+ {
+ a = 0;
+ for (; a < 9; a++)
+ {
+ b = 0;
+ for (; b < 2; b++)
+ c[a + b] = 3;
+ }
+ }
+ }
+ }
+}