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]

[patch][graphite] Fix PR42285


Hi,

The attached patch fixed PR42285 by finishing parsing multiply
expressions like (P * Q + foo) * 9 that should not be handled by
graphite as it cannot handle expressions of the type parameter times
parameter: in this case, P * Q.

2009-12-08  Sebastian Pop  <sebpop@gmail.com>

	PR middle-end/42285
	* graphite-scop-detection.c (graphite_can_represent_init): Also
	handle more complex MULT_EXPRs containing parameters by recursion
	on the structure.

	* testsuite/gfortran.dg/graphite/pr42285.f90: New.

Tested on amd64-linux and spec 2k6, committed to trunk.

Sebastian
From 48f345e8bd5a93286e3ae41d3e6ac950f6112a98 Mon Sep 17 00:00:00 2001
From: Sebastian Pop <sebpop@gmail.com>
Date: Tue, 8 Dec 2009 21:55:31 -0600
Subject: [PATCH] Fix PR42285.

---
 gcc/graphite-scop-detection.c                  |    6 ++++--
 gcc/testsuite/gfortran.dg/graphite/pr42285.f90 |   24 ++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/gfortran.dg/graphite/pr42285.f90

diff --git a/gcc/graphite-scop-detection.c b/gcc/graphite-scop-detection.c
index 50b2e5b..8bef0fd 100644
--- a/gcc/graphite-scop-detection.c
+++ b/gcc/graphite-scop-detection.c
@@ -168,9 +168,11 @@ graphite_can_represent_init (tree e)
 
     case MULT_EXPR:
       if (chrec_contains_symbols (TREE_OPERAND (e, 0)))
-	return host_integerp (TREE_OPERAND (e, 1), 0);
+	return graphite_can_represent_init (TREE_OPERAND (e, 0))
+	  && host_integerp (TREE_OPERAND (e, 1), 0);
       else
-	return host_integerp (TREE_OPERAND (e, 0), 0);
+	return graphite_can_represent_init (TREE_OPERAND (e, 1))
+	  && host_integerp (TREE_OPERAND (e, 0), 0);
 
     case PLUS_EXPR:
     case POINTER_PLUS_EXPR:
diff --git a/gcc/testsuite/gfortran.dg/graphite/pr42285.f90 b/gcc/testsuite/gfortran.dg/graphite/pr42285.f90
new file mode 100644
index 0000000..d496d37
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/graphite/pr42285.f90
@@ -0,0 +1,24 @@
+! { dg-options "-O2 -floop-interchange" }
+
+SUBROUTINE EFGRDM(NCF,NFRG,G,RTRMS,GM,IOPT,K1)
+  IMPLICIT DOUBLE PRECISION (A-H,O-Z)
+  DIMENSION G(*),RTRMS(*),GM(*)
+
+  DUM = 0
+  DO I=1,NFRG
+     DO J=1,3
+        IF (IOPT.EQ.0) THEN
+           GM(K1)=G(K1)
+        END IF
+     END DO
+     DO J=1,3
+        JDX=NCF*9+IOPT*9*NFRG
+        DO M=1,3
+           DUM=DUM+RTRMS(JDX+M)
+        END DO
+        GM(K1)=DUM
+     END DO
+  END DO
+  RETURN
+END SUBROUTINE EFGRDM
+
-- 
1.6.0.4


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