OSDN Git Service

PR graphite/42185
authoraldyh <aldyh@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 15 Dec 2009 15:17:46 +0000 (15:17 +0000)
committeraldyh <aldyh@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 15 Dec 2009 15:17:46 +0000 (15:17 +0000)
        * 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
gcc/graphite-sese-to-poly.c
gcc/testsuite/gfortran.dg/graphite/pr42185.f90 [new file with mode: 0644]

index aaf4a1e..6259415 100644 (file)
@@ -1,3 +1,10 @@
+2009-12-15  Aldy Hernandez  <aldyh@redhat.com>
+
+       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  <ebotcazou@adacore.com>
 
        * config/rs6000/rs6000.md (probe_stack): Use an enclosing SET.
index 1eb0696..370bbff 100644 (file)
@@ -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 (file)
index 0000000..0918f72
--- /dev/null
@@ -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