From 5daf19b17b2b5fff65f64a04d82f85d48251d047 Mon Sep 17 00:00:00 2001 From: aldyh Date: Tue, 15 Dec 2009 15:17:46 +0000 Subject: [PATCH] PR graphite/42185 * graphite-sese-to-poly.c (is_reduction_operation_p): Assert that we are a GIMPLE_ASSIGN. Do not calculate rhs code twice. (follow_ssa_with_commutative_ops): Return NULL on non assignment. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@155256 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 7 +++++++ gcc/graphite-sese-to-poly.c | 12 ++++++++++-- gcc/testsuite/gfortran.dg/graphite/pr42185.f90 | 27 ++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/graphite/pr42185.f90 diff --git a/gcc/ChangeLog b/gcc/ChangeLog index aaf4a1e..6259415 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2009-12-15 Aldy Hernandez + + PR graphite/42185 + * graphite-sese-to-poly.c (is_reduction_operation_p): Assert that + we are a GIMPLE_ASSIGN. Do not calculate rhs code twice. + (follow_ssa_with_commutative_ops): Return NULL on non assignment. + 2009-12-15 Eric Botcazou * config/rs6000/rs6000.md (probe_stack): Use an enclosing SET. diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c index 1eb0696..370bbff 100644 --- a/gcc/graphite-sese-to-poly.c +++ b/gcc/graphite-sese-to-poly.c @@ -2462,9 +2462,14 @@ split_reduction_stmt (gimple stmt) static inline bool is_reduction_operation_p (gimple stmt) { + enum tree_code code; + + gcc_assert (is_gimple_assign (stmt)); + code = gimple_assign_rhs_code (stmt); + return flag_associative_math - && commutative_tree_code (gimple_assign_rhs_code (stmt)) - && associative_tree_code (gimple_assign_rhs_code (stmt)); + && commutative_tree_code (code) + && associative_tree_code (code); } /* Returns true when PHI contains an argument ARG. */ @@ -2500,6 +2505,9 @@ follow_ssa_with_commutative_ops (tree arg, tree lhs) return NULL; } + if (!is_gimple_assign (stmt)) + return NULL; + if (gimple_num_ops (stmt) == 2) return follow_ssa_with_commutative_ops (gimple_assign_rhs1 (stmt), lhs); diff --git a/gcc/testsuite/gfortran.dg/graphite/pr42185.f90 b/gcc/testsuite/gfortran.dg/graphite/pr42185.f90 new file mode 100644 index 0000000..0918f72 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/graphite/pr42185.f90 @@ -0,0 +1,27 @@ +! { dg-compile } +! { dg-options "-fgraphite -O -ffast-math" } + +MODULE powell + INTEGER, PARAMETER :: dp=8 +CONTAINS + SUBROUTINE trsapp (n,npt,xopt,xpt,gq,hq,pq,delta,step,d,g,hd,hs,crvmin) + REAL(dp), DIMENSION(*), INTENT(INOUT) :: step, d, g, hd, hs + LOGICAL :: jump1, jump2 + REAL(dp) :: alpha, angle, angtest, bstep, cf, cth, dd, delsq, dg, dhd, & + reduc, sg, sgk, shs, ss, sth, temp, tempa, tempb + DO i=1,n + dd=dd+d(i)**2 + END DO + mainloop : DO + IF ( .NOT. jump2 ) THEN + IF ( .NOT. jump1 ) THEN + bstep=temp/(ds+SQRT(ds*ds+dd*temp)) + IF (alpha < bstep) THEN + IF (ss < delsq) CYCLE mainloop + END IF + IF (gg <= 1.0e-4_dp*ggbeg) EXIT mainloop + END IF + END IF + END DO mainloop + END SUBROUTINE trsapp +END MODULE powell -- 2.7.4