Patchwork Fix PR47019: parameters of a SCoP are SCEV analyzable.

login
register
mail settings
Submitter Sebastian Pop
Date Dec. 22, 2010, 7:58 p.m.
Message ID <1293047914-20668-1-git-send-email-sebpop@gmail.com>
Download mbox | patch
Permalink /patch/76443/
State New
Headers show

Comments

Sebastian Pop - Dec. 22, 2010, 7:58 p.m.
Hi,

This patch makes scev_analyzable_p return true for SSA_NAMEs defined
outside the analyzed region: these are parameters of the SCoP, and so
they should be propagated without being rewritten out-of-SSA.  I sent
this patch to test on amd64-linux, and I will commit it to trunk after
it passes regstrap.

Sebastian

2010-12-22  Sebastian Pop  <sebastian.pop@amd.com>

	PR tree-optimization/47019
	* sese.h (scev_analyzable_p): Parameters of a SCoP are SCEV analyzable.

	* gfortran.dg/graphite/pr47019.f: New.
---
 gcc/ChangeLog                                |    5 +++++
 gcc/sese.h                                   |    3 ++-
 gcc/testsuite/ChangeLog                      |    5 +++++
 gcc/testsuite/gfortran.dg/graphite/pr47019.f |   12 ++++++++++++
 4 files changed, 24 insertions(+), 1 deletions(-)
 create mode 100644 gcc/testsuite/gfortran.dg/graphite/pr47019.f

Patch

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 944f806..d6211fc 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@ 
+2010-12-22  Sebastian Pop  <sebastian.pop@amd.com>
+
+	PR tree-optimization/47019
+	* sese.h (scev_analyzable_p): Parameters of a SCoP are SCEV analyzable.
+
 2010-12-17  Paolo Bonzini  <bonzini@gnu.org>
 
 	PR c/20385
diff --git a/gcc/sese.h b/gcc/sese.h
index 97807d8..d3b8958 100644
--- a/gcc/sese.h
+++ b/gcc/sese.h
@@ -413,7 +413,8 @@  scev_analyzable_p (tree def, sese region)
   scev = scalar_evolution_in_region (region, loop, def);
 
   return !chrec_contains_undetermined (scev)
-    && TREE_CODE (scev) != SSA_NAME
+    && (TREE_CODE (scev) != SSA_NAME
+	|| !defined_in_sese_p (scev, region))
     && (tree_does_not_contain_chrecs (scev)
 	|| evolution_function_is_affine_p (scev));
 }
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 7db98fc..9df72fb 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@ 
+2010-12-22  Sebastian Pop  <sebastian.pop@amd.com>
+
+	PR tree-optimization/47019
+	* gfortran.dg/graphite/pr47019.f: New.
+
 2010-12-17  Paolo Bonzini  <bonzini@gnu.org>
 
 	PR c/20385
diff --git a/gcc/testsuite/gfortran.dg/graphite/pr47019.f b/gcc/testsuite/gfortran.dg/graphite/pr47019.f
new file mode 100644
index 0000000..69067e9
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/graphite/pr47019.f
@@ -0,0 +1,12 @@ 
+! { dg-options "-O -ftree-pre -fgraphite-identity -fno-tree-copy-prop" }
+
+      subroutine foo (ldmx,ldmy,v)
+      integer :: ldmx, ldmy, v, l, m
+      dimension v(5,ldmx,ldmy)
+      do m = 5, 1, -1
+        do l = m+1, 5
+          v(m,3,2) = v(1,3,2)
+        end do
+        v(m,3,2) = m
+      end do
+      end