OSDN Git Service

* config/vax/vax.h (target_flags, MASK_UNIX_ASM, MASK_VAXC_ALIGNMENT)
[pf3gnuchains/gcc-fork.git] / gcc / tree-data-ref.c
index 5239821..882163d 100644 (file)
@@ -1,5 +1,5 @@
 /* Data references and dependences detectors.
-   Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
    Contributed by Sebastian Pop <s.pop@laposte.net>
 
 This file is part of GCC.
@@ -109,9 +109,9 @@ array_base_name_differ_p (struct data_reference *a,
 {
   tree base_a = DR_BASE_NAME (a);
   tree base_b = DR_BASE_NAME (b);
-  tree ta = TREE_TYPE (base_a);
-  tree tb = TREE_TYPE (base_b);
 
+  if (!base_a || !base_b)
+    return false;
 
   /* Determine if same base.  Example: for the array accesses
      a[i], b[i] or pointer accesses *a, *b, bases are a, b.  */
@@ -179,24 +179,6 @@ array_base_name_differ_p (struct data_reference *a,
       return true;
     }
 
-  if (!alias_sets_conflict_p (get_alias_set (base_a), get_alias_set (base_b)))
-    {
-      *differ_p = true;
-      return true;
-    }
-
-  /* An instruction writing through a restricted pointer is
-     "independent" of any instruction reading or writing through a
-     different pointer, in the same block/scope.  */
-  if ((TREE_CODE (ta) == POINTER_TYPE && TYPE_RESTRICT (ta)
-       && !DR_IS_READ(a))
-      || (TREE_CODE (tb) == POINTER_TYPE && TYPE_RESTRICT (tb)
-         && !DR_IS_READ(b)))
-    {
-      *differ_p = true;
-      return true;
-    }
-
   return false;
 }
 
@@ -1111,7 +1093,7 @@ compute_overlap_steps_for_affine_univar (int niter, int step_a, int step_b,
    | y (t, u, v) = {{0, +, 1336}_u, +, 1}_v
    | z (t, u, v) = {{{0, +, 1}_t, +, 1335}_u, +, 1}_v
 
-   FORNOW: This is a specialized implementation for a case occuring in
+   FORNOW: This is a specialized implementation for a case occurring in
    a common benchmark.  Implement the general algorithm.  */
 
 static void
@@ -1781,15 +1763,15 @@ subscript_dependence_tester (struct data_dependence_relation *ddr)
 
    DDR is the data dependence relation to build a vector from.
    NB_LOOPS is the total number of loops we are considering.
-   FIRST_LOOP is the loop->num of the first loop in the analyzed 
+   FIRST_LOOP_DEPTH is the loop->depth of the first loop in the analyzed
    loop nest.  
    Return FALSE if the dependence relation is outside of the loop nest
-   starting with FIRST_LOOP
+   starting at FIRST_LOOP_DEPTH
    Return TRUE otherwise.  */
 
 static bool
 build_classic_dist_vector (struct data_dependence_relation *ddr, 
-                          int nb_loops, unsigned int first_loop)
+                          int nb_loops, int first_loop_depth)
 {
   unsigned i;
   lambda_vector dist_v, init_v;
@@ -1819,19 +1801,18 @@ build_classic_dist_vector (struct data_dependence_relation *ddr,
       if (TREE_CODE (access_fn_a) == POLYNOMIAL_CHREC 
          && TREE_CODE (access_fn_b) == POLYNOMIAL_CHREC)
        {
-         int dist, loop_nb;
+         int dist, loop_nb, loop_depth;
          int loop_nb_a = CHREC_VARIABLE (access_fn_a);
          int loop_nb_b = CHREC_VARIABLE (access_fn_b);
          struct loop *loop_a = current_loops->parray[loop_nb_a];
          struct loop *loop_b = current_loops->parray[loop_nb_b];
-         struct loop *loop_first = current_loops->parray[first_loop];
 
          /* If the loop for either variable is at a lower depth than 
             the first_loop's depth, then we can't possibly have a
             dependency at this level of the loop.  */
             
-         if (loop_a->depth < loop_first->depth
-             || loop_b->depth < loop_first->depth)
+         if (loop_a->depth < first_loop_depth
+             || loop_b->depth < first_loop_depth)
            return false;
 
          if (loop_nb_a != loop_nb_b
@@ -1862,13 +1843,13 @@ build_classic_dist_vector (struct data_dependence_relation *ddr,
             | endloop_1
             In this case, the dependence is carried by loop_1.  */
          loop_nb = loop_nb_a < loop_nb_b ? loop_nb_a : loop_nb_b;
-         loop_nb -= first_loop;
+         loop_depth = current_loops->parray[loop_nb]->depth - first_loop_depth;
 
          /* If the loop number is still greater than the number of
             loops we've been asked to analyze, or negative,
             something is borked.  */
-         gcc_assert (loop_nb >= 0);
-         gcc_assert (loop_nb < nb_loops);
+         gcc_assert (loop_depth >= 0);
+         gcc_assert (loop_depth < nb_loops);
          if (chrec_contains_undetermined (SUB_DISTANCE (subscript)))
            {
              non_affine_dependence_relation (ddr);
@@ -1883,15 +1864,15 @@ build_classic_dist_vector (struct data_dependence_relation *ddr,
             |   ... = T[i][i]
             | endloop
             There is no dependence.  */
-         if (init_v[loop_nb] != 0
-             && dist_v[loop_nb] != dist)
+         if (init_v[loop_depth] != 0
+             && dist_v[loop_depth] != dist)
            {
              finalize_ddr_dependent (ddr, chrec_known);
              return true;
            }
 
-         dist_v[loop_nb] = dist;
-         init_v[loop_nb] = 1;
+         dist_v[loop_depth] = dist;
+         init_v[loop_depth] = 1;
        }
     }
   
@@ -1906,43 +1887,43 @@ build_classic_dist_vector (struct data_dependence_relation *ddr,
     struct loop *lca, *loop_a, *loop_b;
     struct data_reference *a = DDR_A (ddr);
     struct data_reference *b = DDR_B (ddr);
-    int lca_nb;
+    int lca_depth;
     loop_a = loop_containing_stmt (DR_STMT (a));
     loop_b = loop_containing_stmt (DR_STMT (b));
     
     /* Get the common ancestor loop.  */
     lca = find_common_loop (loop_a, loop_b); 
     
-    lca_nb = lca->num;
-    lca_nb -= first_loop;
-    gcc_assert (lca_nb >= 0);
-    gcc_assert (lca_nb < nb_loops);
+    lca_depth = lca->depth;
+    lca_depth -= first_loop_depth;
+    gcc_assert (lca_depth >= 0);
+    gcc_assert (lca_depth < nb_loops);
 
     /* For each outer loop where init_v is not set, the accesses are
        in dependence of distance 1 in the loop.  */
     if (lca != loop_a
        && lca != loop_b
-       && init_v[lca_nb] == 0)
-      dist_v[lca_nb] = 1;
+       && init_v[lca_depth] == 0)
+      dist_v[lca_depth] = 1;
     
     lca = lca->outer;
     
     if (lca)
       {
-       lca_nb = lca->num - first_loop;
+       lca_depth = lca->depth - first_loop_depth;
        while (lca->depth != 0)
          {
            /* If we're considering just a sub-nest, then don't record
               any information on the outer loops.  */
-           if (lca_nb < 0)
+           if (lca_depth < 0)
              break;
 
-           gcc_assert (lca_nb < nb_loops);
+           gcc_assert (lca_depth < nb_loops);
 
-           if (init_v[lca_nb] == 0)
-             dist_v[lca_nb] = 1;
+           if (init_v[lca_depth] == 0)
+             dist_v[lca_depth] = 1;
            lca = lca->outer;
-           lca_nb = lca->num - first_loop;
+           lca_depth = lca->depth - first_loop_depth;
          
          }
       }
@@ -1957,15 +1938,15 @@ build_classic_dist_vector (struct data_dependence_relation *ddr,
 
    DDR is the data dependence relation to build a vector from.
    NB_LOOPS is the total number of loops we are considering.
-   FIRST_LOOP is the loop->num of the first loop in the analyzed 
+   FIRST_LOOP_DEPTH is the loop->depth of the first loop in the analyzed 
    loop nest.
    Return FALSE if the dependence relation is outside of the loop nest
-   starting with FIRST_LOOP
+   at FIRST_LOOP_DEPTH
    Return TRUE otherwise.  */
 
 static bool
 build_classic_dir_vector (struct data_dependence_relation *ddr, 
-                         int nb_loops, unsigned int first_loop)
+                         int nb_loops, int first_loop_depth)
 {
   unsigned i;
   lambda_vector dir_v, init_v;
@@ -1994,20 +1975,19 @@ build_classic_dir_vector (struct data_dependence_relation *ddr,
       if (TREE_CODE (access_fn_a) == POLYNOMIAL_CHREC
          && TREE_CODE (access_fn_b) == POLYNOMIAL_CHREC)
        {
-         int dist, loop_nb;
+         int dist, loop_nb, loop_depth;
          enum data_dependence_direction dir = dir_star;
          int loop_nb_a = CHREC_VARIABLE (access_fn_a);
          int loop_nb_b = CHREC_VARIABLE (access_fn_b);
          struct loop *loop_a = current_loops->parray[loop_nb_a];
          struct loop *loop_b = current_loops->parray[loop_nb_b];
-         struct loop *loop_first = current_loops->parray[first_loop];
  
          /* If the loop for either variable is at a lower depth than 
             the first_loop's depth, then we can't possibly have a
             dependency at this level of the loop.  */
             
-         if (loop_a->depth < loop_first->depth
-             || loop_b->depth < loop_first->depth)
+         if (loop_a->depth < first_loop_depth
+             || loop_b->depth < first_loop_depth)
            return false;
 
          if (loop_nb_a != loop_nb_b
@@ -2038,13 +2018,13 @@ build_classic_dir_vector (struct data_dependence_relation *ddr,
             | endloop_1
             In this case, the dependence is carried by loop_1.  */
          loop_nb = loop_nb_a < loop_nb_b ? loop_nb_a : loop_nb_b;
-         loop_nb -= first_loop;
+         loop_depth = current_loops->parray[loop_nb]->depth - first_loop_depth;
 
          /* If the loop number is still greater than the number of
             loops we've been asked to analyze, or negative,
             something is borked.  */
-         gcc_assert (loop_nb >= 0);
-         gcc_assert (loop_nb < nb_loops);
+         gcc_assert (loop_depth >= 0);
+         gcc_assert (loop_depth < nb_loops);
 
          if (chrec_contains_undetermined (SUB_DISTANCE (subscript)))
            {
@@ -2067,17 +2047,17 @@ build_classic_dir_vector (struct data_dependence_relation *ddr,
             |   ... = T[i][i]
             | endloop
             There is no dependence.  */
-         if (init_v[loop_nb] != 0
+         if (init_v[loop_depth] != 0
              && dir != dir_star
-             && (enum data_dependence_direction) dir_v[loop_nb] != dir
-             && (enum data_dependence_direction) dir_v[loop_nb] != dir_star)
+             && (enum data_dependence_direction) dir_v[loop_depth] != dir
+             && (enum data_dependence_direction) dir_v[loop_depth] != dir_star)
            {
              finalize_ddr_dependent (ddr, chrec_known);
              return true;
            }
          
-         dir_v[loop_nb] = dir;
-         init_v[loop_nb] = 1;
+         dir_v[loop_depth] = dir;
+         init_v[loop_depth] = 1;
        }
     }
   
@@ -2092,41 +2072,41 @@ build_classic_dir_vector (struct data_dependence_relation *ddr,
     struct loop *lca, *loop_a, *loop_b;
     struct data_reference *a = DDR_A (ddr);
     struct data_reference *b = DDR_B (ddr);
-    int lca_nb;
+    int lca_depth;
     loop_a = loop_containing_stmt (DR_STMT (a));
     loop_b = loop_containing_stmt (DR_STMT (b));
     
     /* Get the common ancestor loop.  */
     lca = find_common_loop (loop_a, loop_b); 
-    lca_nb = lca->num - first_loop;
+    lca_depth = lca->depth - first_loop_depth;
 
-    gcc_assert (lca_nb >= 0);
-    gcc_assert (lca_nb < nb_loops);
+    gcc_assert (lca_depth >= 0);
+    gcc_assert (lca_depth < nb_loops);
 
     /* For each outer loop where init_v is not set, the accesses are
        in dependence of distance 1 in the loop.  */
     if (lca != loop_a
        && lca != loop_b
-       && init_v[lca_nb] == 0)
-      dir_v[lca_nb] = dir_positive;
+       && init_v[lca_depth] == 0)
+      dir_v[lca_depth] = dir_positive;
     
     lca = lca->outer;
     if (lca)
       {
-       lca_nb = lca->num - first_loop;
+       lca_depth = lca->depth - first_loop_depth;
        while (lca->depth != 0)
          {
            /* If we're considering just a sub-nest, then don't record
               any information on the outer loops.  */
-           if (lca_nb < 0)
+           if (lca_depth < 0)
              break;
 
-           gcc_assert (lca_nb < nb_loops);
+           gcc_assert (lca_depth < nb_loops);
 
-           if (init_v[lca_nb] == 0)
-             dir_v[lca_nb] = dir_positive;
+           if (init_v[lca_depth] == 0)
+             dir_v[lca_depth] = dir_positive;
            lca = lca->outer;
-           lca_nb = lca->num - first_loop;
+           lca_depth = lca->depth - first_loop_depth;
           
          }
       }
@@ -2330,8 +2310,8 @@ compute_data_dependences_for_loop (unsigned nb_loops,
         chrec_dont_know.  */
       ddr = initialize_data_dependence_relation (NULL, NULL);
       VARRAY_PUSH_GENERIC_PTR (*dependence_relations, ddr);
-      build_classic_dist_vector (ddr, nb_loops, loop->num);
-      build_classic_dir_vector (ddr, nb_loops, loop->num);
+      build_classic_dist_vector (ddr, nb_loops, loop->depth);
+      build_classic_dir_vector (ddr, nb_loops, loop->depth);
       return;
     }
 
@@ -2342,10 +2322,10 @@ compute_data_dependences_for_loop (unsigned nb_loops,
     {
       struct data_dependence_relation *ddr;
       ddr = VARRAY_GENERIC_PTR (allrelations, i);
-      if (build_classic_dist_vector (ddr, nb_loops, loop->num))
+      if (build_classic_dist_vector (ddr, nb_loops, loop->depth))
        {
          VARRAY_PUSH_GENERIC_PTR (*dependence_relations, ddr);
-         build_classic_dir_vector (ddr, nb_loops, loop->num);
+         build_classic_dir_vector (ddr, nb_loops, loop->depth);
        }
     }
 }