Patchwork [44/65] Do not rewrite out of SSA scalar phi nodes that can be scev_analyzable_p.

login
register
mail settings
Submitter Sebastian Pop
Date Aug. 2, 2010, 8:20 p.m.
Message ID <1280780438-17543-45-git-send-email-sebpop@gmail.com>
Download mbox | patch
Permalink /patch/60641/
State New
Headers show

Comments

Sebastian Pop - Aug. 2, 2010, 8:20 p.m.
From: spop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>

2010-07-15  Sebastian Pop  <sebastian.pop@amd.com>

	* graphite-sese-to-poly.c (reduction_phi_p): Do not rewrite out of
	SSA scalar phi nodes that can be scev_analyzable_p.

	* gfortran.dg/graphite/id-20.f: Adjust testcase.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/graphite@162252 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog                              |    5 +++++
 gcc/ChangeLog.graphite                     |    7 +++++++
 gcc/graphite-sese-to-poly.c                |   20 ++++----------------
 gcc/testsuite/ChangeLog                    |    4 ++++
 gcc/testsuite/gfortran.dg/graphite/id-20.f |   12 +++++++++---
 5 files changed, 29 insertions(+), 19 deletions(-)

Patch

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 0433d9b..f153d76 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,10 @@ 
 2010-08-02  Sebastian Pop  <sebastian.pop@amd.com>
 
+	* graphite-sese-to-poly.c (reduction_phi_p): Do not rewrite out of
+	SSA scalar phi nodes that can be scev_analyzable_p.
+
+2010-08-02  Sebastian Pop  <sebastian.pop@amd.com>
+
 	* graphite-sese-to-poly.c (rewrite_close_phi_out_of_ssa): Correctly
 	handle SSA_NAME_IS_DEFAULT_DEF.
 
diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite
index 27cacc0..1ddd731 100644
--- a/gcc/ChangeLog.graphite
+++ b/gcc/ChangeLog.graphite
@@ -1,5 +1,12 @@ 
 2010-07-15  Sebastian Pop  <sebastian.pop@amd.com>
 
+	* graphite-sese-to-poly.c (reduction_phi_p): Do not rewrite out of
+	SSA scalar phi nodes that can be scev_analyzable_p.
+
+	* gfortran.dg/graphite/id-20.f: Adjust testcase.
+
+2010-07-15  Sebastian Pop  <sebastian.pop@amd.com>
+
 	* graphite-sese-to-poly.c (rewrite_close_phi_out_of_ssa): Correctly
 	handle SSA_NAME_IS_DEFAULT_DEF.
 
diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
index 0420285..7244ba9 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -165,8 +165,6 @@  static bool
 reduction_phi_p (sese region, gimple_stmt_iterator *psi)
 {
   loop_p loop;
-  tree scev;
-  affine_iv iv;
   gimple phi = gsi_stmt (*psi);
   tree res = gimple_phi_result (phi);
 
@@ -189,11 +187,11 @@  reduction_phi_p (sese region, gimple_stmt_iterator *psi)
       return false;
     }
 
-  /* Main induction variables with constant strides in LOOP are not
-     reductions.  */
-  if (simple_iv (loop, loop, res, &iv, true))
+  if (scev_analyzable_p (res, region))
     {
-      if (integer_zerop (iv.step))
+      tree scev = scalar_evolution_in_region (region, loop, res);
+
+      if (evolution_function_is_invariant_p (scev, loop->num))
 	remove_invariant_phi (region, psi);
       else
 	gsi_next (psi);
@@ -201,16 +199,6 @@  reduction_phi_p (sese region, gimple_stmt_iterator *psi)
       return false;
     }
 
-  scev = scalar_evolution_in_region (region, loop, res);
-  if (chrec_contains_undetermined (scev))
-    return true;
-
-  if (evolution_function_is_invariant_p (scev, loop->num))
-    {
-      remove_invariant_phi (region, psi);
-      return false;
-    }
-
   /* All the other cases are considered reductions.  */
   return true;
 }
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 76288ae..c56694e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,9 @@ 
 2010-08-02  Sebastian Pop  <sebastian.pop@amd.com>
 
+	* gfortran.dg/graphite/id-20.f: Adjust testcase.
+
+2010-08-02  Sebastian Pop  <sebastian.pop@amd.com>
+
 	* gcc.dg/graphite/pr42729.c: New.
 
 2010-08-02  Sebastian Pop  <sebastian.pop@amd.com>
diff --git a/gcc/testsuite/gfortran.dg/graphite/id-20.f b/gcc/testsuite/gfortran.dg/graphite/id-20.f
index 110ae3f..795cb1b 100644
--- a/gcc/testsuite/gfortran.dg/graphite/id-20.f
+++ b/gcc/testsuite/gfortran.dg/graphite/id-20.f
@@ -1,4 +1,10 @@ 
-      DO 32 MB=1,NVIRA
-     *                     PVIRA(MA,MB)*(EA(MA+NOA)+EA(MB+NOA))*PT5
-   32 CONTINUE
+! { dg-options "-O3 -ffast-math" }
+
+      DIMENSION FPQR(25,25,25)
+      INTEGER P,Q,R
+            DO 130 R=1,N4MAX,2
+               IF(P.GT.1) THEN
+                  FPQR(P,Q,R)= RM2*FPQR(P,Q,R-2)*REC(P+Q+R-2)
+               END IF
+  130       RM2= RM2+TWO
       END