OSDN Git Service

2012-04-03 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 3 Apr 2012 13:05:58 +0000 (13:05 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 3 Apr 2012 13:05:58 +0000 (13:05 +0000)
Backport from mainline
2012-03-15  Richard Guenther  <rguenther@suse.de>

PR middle-end/52580
* tree-data-ref.c (subscript_dependence_tester_1): Check
all dimensions for non-conflicting access functions.

* gfortran.dg/vect/pr52580.f: New testcase.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@186107 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/vect/pr52580.f [new file with mode: 0644]
gcc/tree-data-ref.c

index 18a2741..c3e2d18 100644 (file)
@@ -1,6 +1,15 @@
 2012-04-03  Richard Guenther  <rguenther@suse.de>
 
        Backport from mainline
 2012-04-03  Richard Guenther  <rguenther@suse.de>
 
        Backport from mainline
+       2012-03-15  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/52580
+       * tree-data-ref.c (subscript_dependence_tester_1): Check
+       all dimensions for non-conflicting access functions.
+
+2012-04-03  Richard Guenther  <rguenther@suse.de>
+
+       Backport from mainline
        2012-03-06  Richard Guenther  <rguenther@suse.de>
 
        PR middle-end/52493
        2012-03-06  Richard Guenther  <rguenther@suse.de>
 
        PR middle-end/52493
index d37fed4..27850d6 100644 (file)
@@ -1,6 +1,14 @@
 2012-04-03  Richard Guenther  <rguenther@suse.de>
 
        Backport from mainline
 2012-04-03  Richard Guenther  <rguenther@suse.de>
 
        Backport from mainline
+       2012-03-15  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/52580
+       * gfortran.dg/vect/pr52580.f: New testcase.
+
+2012-04-03  Richard Guenther  <rguenther@suse.de>
+
+       Backport from mainline
        2012-03-06  Richard Guenther  <rguenther@suse.de>
 
        PR middle-end/52493
        2012-03-06  Richard Guenther  <rguenther@suse.de>
 
        PR middle-end/52493
diff --git a/gcc/testsuite/gfortran.dg/vect/pr52580.f b/gcc/testsuite/gfortran.dg/vect/pr52580.f
new file mode 100644 (file)
index 0000000..eab9fa5
--- /dev/null
@@ -0,0 +1,33 @@
+! { dg-do compile }
+! { dg-require-effective-target vect_double }
+      SUBROUTINE CALC2
+      IMPLICIT REAL*8  (A-H, O-Z)
+      PARAMETER (N1=1335, N2=1335)
+
+      COMMON  U(N1,N2), V(N1,N2), P(N1,N2),
+     *        UNEW(N1,N2), VNEW(N1,N2),
+     1        PNEW(N1,N2), UOLD(N1,N2),
+     *        VOLD(N1,N2), POLD(N1,N2),
+     2        CU(N1,N2), CV(N1,N2),
+     *        Z(N1,N2), H(N1,N2), PSI(N1,N2)
+      COMMON /CONS/ DT,TDT,DX,DY,A,ALPHA,ITMAX,MPRINT,M,N,MP1,
+     1              NP1,EL,PI,TPI,DI,DJ,PCF
+      TDTS8 = TDT/8.D0
+      TDTSDX = TDT/DX
+      TDTSDY = TDT/DY
+
+      DO 200 J=1,N
+      DO 200 I=1,M
+      UNEW(I+1,J) = UOLD(I+1,J)+
+     1    TDTS8*(Z(I+1,J+1)+Z(I+1,J))*(CV(I+1,J+1)+CV(I,J+1)+CV(I,J)
+     2       +CV(I+1,J))-TDTSDX*(H(I+1,J)-H(I,J))
+      VNEW(I,J+1) = VOLD(I,J+1)-TDTS8*(Z(I+1,J+1)+Z(I,J+1))
+     1       *(CU(I+1,J+1)+CU(I,J+1)+CU(I,J)+CU(I+1,J))
+     2       -TDTSDY*(H(I,J+1)-H(I,J))
+      PNEW(I,J) = POLD(I,J)-TDTSDX*(CU(I+1,J)-CU(I,J))
+     1       -TDTSDY*(CV(I,J+1)-CV(I,J))
+  200 CONTINUE
+      RETURN
+      END
+! { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 1 "vect" } }
+! { dg-final { cleanup-tree-dump "vect" } }
index 4f65401..949dbce 100644 (file)
@@ -3416,6 +3416,7 @@ subscript_dependence_tester_1 (struct data_dependence_relation *ddr,
   unsigned int i;
   tree last_conflicts;
   struct subscript *subscript;
   unsigned int i;
   tree last_conflicts;
   struct subscript *subscript;
+  tree res = NULL_TREE;
 
   for (i = 0; VEC_iterate (subscript_p, DDR_SUBSCRIPTS (ddr), i, subscript);
        i++)
 
   for (i = 0; VEC_iterate (subscript_p, DDR_SUBSCRIPTS (ddr), i, subscript);
        i++)
@@ -3427,40 +3428,43 @@ subscript_dependence_tester_1 (struct data_dependence_relation *ddr,
                                      &overlaps_a, &overlaps_b,
                                      &last_conflicts, loop_nest);
 
                                      &overlaps_a, &overlaps_b,
                                      &last_conflicts, loop_nest);
 
+      if (SUB_CONFLICTS_IN_A (subscript))
+       free_conflict_function (SUB_CONFLICTS_IN_A (subscript));
+      if (SUB_CONFLICTS_IN_B (subscript))
+       free_conflict_function (SUB_CONFLICTS_IN_B (subscript));
+
+      SUB_CONFLICTS_IN_A (subscript) = overlaps_a;
+      SUB_CONFLICTS_IN_B (subscript) = overlaps_b;
+      SUB_LAST_CONFLICT (subscript) = last_conflicts;
+
+      /* If there is any undetermined conflict function we have to
+         give a conservative answer in case we cannot prove that
+        no dependence exists when analyzing another subscript.  */
       if (CF_NOT_KNOWN_P (overlaps_a)
          || CF_NOT_KNOWN_P (overlaps_b))
        {
       if (CF_NOT_KNOWN_P (overlaps_a)
          || CF_NOT_KNOWN_P (overlaps_b))
        {
-         finalize_ddr_dependent (ddr, chrec_dont_know);
-         dependence_stats.num_dependence_undetermined++;
-         free_conflict_function (overlaps_a);
-         free_conflict_function (overlaps_b);
-         return false;
+         res = chrec_dont_know;
+         continue;
        }
 
        }
 
+      /* When there is a subscript with no dependence we can stop.  */
       else if (CF_NO_DEPENDENCE_P (overlaps_a)
               || CF_NO_DEPENDENCE_P (overlaps_b))
        {
       else if (CF_NO_DEPENDENCE_P (overlaps_a)
               || CF_NO_DEPENDENCE_P (overlaps_b))
        {
-         finalize_ddr_dependent (ddr, chrec_known);
-         dependence_stats.num_dependence_independent++;
-         free_conflict_function (overlaps_a);
-         free_conflict_function (overlaps_b);
-         return false;
-       }
-
-      else
-       {
-         if (SUB_CONFLICTS_IN_A (subscript))
-           free_conflict_function (SUB_CONFLICTS_IN_A (subscript));
-         if (SUB_CONFLICTS_IN_B (subscript))
-           free_conflict_function (SUB_CONFLICTS_IN_B (subscript));
-
-         SUB_CONFLICTS_IN_A (subscript) = overlaps_a;
-         SUB_CONFLICTS_IN_B (subscript) = overlaps_b;
-         SUB_LAST_CONFLICT (subscript) = last_conflicts;
+         res = chrec_known;
+         break;
        }
     }
 
        }
     }
 
-  return true;
+  if (res == NULL_TREE)
+    return true;
+
+  if (res == chrec_known)
+    dependence_stats.num_dependence_independent++;
+  else
+    dependence_stats.num_dependence_undetermined++;
+  finalize_ddr_dependent (ddr, res);
+  return false;
 }
 
 /* Computes the conflicting iterations in LOOP_NEST, and initialize DDR.  */
 }
 
 /* Computes the conflicting iterations in LOOP_NEST, and initialize DDR.  */