OSDN Git Service

2008-05-16 Sebastian Pop <sebastian.pop@amd.com>
authorspop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 16 May 2008 16:02:02 +0000 (16:02 +0000)
committerspop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 16 May 2008 16:02:02 +0000 (16:02 +0000)
    Jan Sjodin  <jan.sjodin@amd.com>

PR tree-optimization/36228
* tree-data-ref.c (initialize_data_dependence_relation): Fast dependence
test when the references are the same, call compute_self_dependence.
* tree-data-ref.h (struct data_dependence_relation): Add self_reference_p.
(DDR_SELF_REFERENCE): New.

* testsuite/gcc.dg/vect/pr36228.c: New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@135426 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 1889bf2..b79156c 100644 (file)
@@ -1,3 +1,9 @@
+2008-05-16  Sebastian Pop  <sebastian.pop@amd.com>
+           Jan Sjodin  <jan.sjodin@amd.com>
+
+       PR tree-optimization/36228
+       * gcc.dg/vect/pr36228.c: New.
+
 2008-05-16  Hans-Peter Nilsson  <hp@axis.com>
 
        * gfortran.dg/f2003_io_4.f03, gfortran.dg/f2003_io_5.f03,
 2008-05-16  Hans-Peter Nilsson  <hp@axis.com>
 
        * gfortran.dg/f2003_io_4.f03, gfortran.dg/f2003_io_5.f03,
diff --git a/gcc/testsuite/gcc.dg/vect/pr36228.c b/gcc/testsuite/gcc.dg/vect/pr36228.c
new file mode 100644 (file)
index 0000000..7393375
--- /dev/null
@@ -0,0 +1,31 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -fdump-tree-vect-details" } */
+
+#define COLS         8
+#define ROWS         8
+
+int
+t_run_test(void);
+
+int
+t_run_test()
+{
+     int k_1,i_1, j_1;
+     static signed char f_1[ROWS][COLS] ;
+     static long F_1[ROWS][COLS] ;
+     long cosMatrixA[ROWS][COLS] ;
+
+     for( k_1 = 0 ; k_1 < COLS ; k_1++ )
+        {
+            for( i_1 = 0 ; i_1 < ROWS ; i_1++ )
+            {
+                for( j_1 = 0 ; j_1 < COLS ; j_1++ )
+                    F_1[i_1][j_1] += f_1[i_1][k_1] * cosMatrixA[k_1][j_1] ;
+            }
+        }
+
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "versioning for alias required" 0 "vect" } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
index 90ce7e9..7e9c99f 100644 (file)
@@ -1265,6 +1265,8 @@ dr_may_alias_p (const struct data_reference *a, const struct data_reference *b)
   return true;
 }
 
   return true;
 }
 
+static void compute_self_dependence (struct data_dependence_relation *);
+
 /* Initialize a data dependence relation between data accesses A and
    B.  NB_LOOPS is the number of loops surrounding the references: the
    size of the classic distance/direction vectors.  */
 /* Initialize a data dependence relation between data accesses A and
    B.  NB_LOOPS is the number of loops surrounding the references: the
    size of the classic distance/direction vectors.  */
@@ -1299,6 +1301,20 @@ initialize_data_dependence_relation (struct data_reference *a,
       return res;
     }
 
       return res;
     }
 
+  /* When the references are exactly the same, don't spend time doing
+     the data dependence tests, just initialize the ddr and return.  */
+  if (operand_equal_p (DR_REF (a), DR_REF (b), 0))
+    {
+      DDR_AFFINE_P (res) = true;
+      DDR_ARE_DEPENDENT (res) = NULL_TREE;
+      DDR_SUBSCRIPTS (res) = VEC_alloc (subscript_p, heap, DR_NUM_DIMENSIONS (a));
+      DDR_LOOP_NEST (res) = loop_nest;
+      DDR_INNER_LOOP (res) = 0;
+      DDR_SELF_REFERENCE (res) = true;
+      compute_self_dependence (res);
+      return res;
+    }
+
   /* If the references do not access the same object, we do not know
      whether they alias or not.  */
   if (!operand_equal_p (DR_BASE_OBJECT (a), DR_BASE_OBJECT (b), 0))
   /* If the references do not access the same object, we do not know
      whether they alias or not.  */
   if (!operand_equal_p (DR_BASE_OBJECT (a), DR_BASE_OBJECT (b), 0))
@@ -1324,6 +1340,7 @@ initialize_data_dependence_relation (struct data_reference *a,
   DDR_SUBSCRIPTS (res) = VEC_alloc (subscript_p, heap, DR_NUM_DIMENSIONS (a));
   DDR_LOOP_NEST (res) = loop_nest;
   DDR_INNER_LOOP (res) = 0;
   DDR_SUBSCRIPTS (res) = VEC_alloc (subscript_p, heap, DR_NUM_DIMENSIONS (a));
   DDR_LOOP_NEST (res) = loop_nest;
   DDR_INNER_LOOP (res) = 0;
+  DDR_SELF_REFERENCE (res) = false;
 
   for (i = 0; i < DR_NUM_DIMENSIONS (a); i++)
     {
 
   for (i = 0; i < DR_NUM_DIMENSIONS (a); i++)
     {
@@ -3798,7 +3815,8 @@ compute_affine_dependence (struct data_dependence_relation *ddr,
     }
 
   /* Analyze only when the dependence relation is not yet known.  */
     }
 
   /* Analyze only when the dependence relation is not yet known.  */
-  if (DDR_ARE_DEPENDENT (ddr) == NULL_TREE)
+  if (DDR_ARE_DEPENDENT (ddr) == NULL_TREE
+      && !DDR_SELF_REFERENCE (ddr))
     {
       dependence_stats.num_dependence_tests++;
 
     {
       dependence_stats.num_dependence_tests++;
 
index 8db6f73..5e668cb 100644 (file)
@@ -221,6 +221,10 @@ struct data_dependence_relation
      a distance vector.  */
   bool affine_p;
 
      a distance vector.  */
   bool affine_p;
 
+  /* Set to true when the dependence relation is on the same data
+     access.  */
+  bool self_reference_p;
+
   /* A "yes/no/maybe" field for the dependence relation:
      
      - when "ARE_DEPENDENT == NULL_TREE", there exist a dependence
   /* A "yes/no/maybe" field for the dependence relation:
      
      - when "ARE_DEPENDENT == NULL_TREE", there exist a dependence
@@ -273,6 +277,7 @@ DEF_VEC_ALLOC_P(ddr_p,heap);
    the loop nest.  */
 #define DDR_NB_LOOPS(DDR) (VEC_length (loop_p, DDR_LOOP_NEST (DDR)))
 #define DDR_INNER_LOOP(DDR) DDR->inner_loop
    the loop nest.  */
 #define DDR_NB_LOOPS(DDR) (VEC_length (loop_p, DDR_LOOP_NEST (DDR)))
 #define DDR_INNER_LOOP(DDR) DDR->inner_loop
+#define DDR_SELF_REFERENCE(DDR) DDR->self_reference_p
 
 #define DDR_DIST_VECTS(DDR) ((DDR)->dist_vects)
 #define DDR_DIR_VECTS(DDR) ((DDR)->dir_vects)
 
 #define DDR_DIST_VECTS(DDR) ((DDR)->dist_vects)
 #define DDR_DIR_VECTS(DDR) ((DDR)->dir_vects)