This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PR graphite/42185


> Hm?  But that's not the same.  Also it doesn't cover unary operations
> thus it only ever will have an SSA name to follow in case of a plain
> SSA name copy.  Thus I don't think this is what is intended.

You are correct.  Sorry for the rushed fix.

Below I've cleaned up is_reduction_operation_p a bit, and I put in an
assert.  Now it's up to the caller to make sure the statement is an
assignment statement.

There are only two callers to is_reduction_operation_p.  I have fixed
follow_ssa_with_commutative_ops to only call is_reduction_operation_p on
an assignment.  The other caller is detect_commutative_reduction_assign
which is already assured to have a GIMPLE_ASSIGN.

I am still testing, but preliminary tests of graphite.exp are good.  OK
for trunk pending tests?

	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.

Index: testsuite/gfortran.dg/graphite/pr42185.f90
===================================================================
--- testsuite/gfortran.dg/graphite/pr42185.f90	(revision 0)
+++ testsuite/gfortran.dg/graphite/pr42185.f90	(revision 0)
@@ -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
Index: graphite-sese-to-poly.c
===================================================================
--- graphite-sese-to-poly.c	(revision 155214)
+++ graphite-sese-to-poly.c	(working copy)
@@ -2458,9 +2458,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.  */
@@ -2496,6 +2501,9 @@ follow_ssa_with_commutative_ops (tree ar
       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);
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]