OSDN Git Service

* flow.c (find_unreachable_blocks): New function.
[pf3gnuchains/gcc-fork.git] / gcc / dependence.c
index a8174c1..3bfe34a 100644 (file)
@@ -1,5 +1,3 @@
-/* CYGNUS LOCAL dependency analysis */
-
 /* Analyze loop dependencies
    Copyright (C) 2000 Free Software Foundation, Inc.
 
@@ -29,6 +27,7 @@ Boston, MA 02111-1307, USA.  */
 #include "system.h"
 
 #include "rtl.h"
+#include "expr.h"
 #include "tree.h"
 #include "c-common.h"
 #include "flags.h"
@@ -60,13 +59,15 @@ Boston, MA 02111-1307, USA.  */
    dependence to the dep_chain
 */
 
-enum dependence_type {flow, anti, output, none};
+enum dependence_type {dt_flow, dt_anti, dt_output, dt_none};
+#if 0
 static const char * dependence_string [] = {"flow", "anti", "output", "none"};
-
+#endif
 enum direction_type {lt, le, eq, gt, ge, star, independent, undef};
+#if 0
 static const char * direction_string [] = {"<", "<=", "=", ">", ">=", "*",
                                           "INDEPENDENT", "UNDEFINED"};
-
+#endif
 enum def_use_type {def, use, init_def_use};
 
 enum du_status_type {seen, unseen};
@@ -89,7 +90,7 @@ typedef struct def_use
   /* this expression */
   tree expression;
   /* our name */
-  char *variable;
+  const char *variable;
   /* def or use */
   enum def_use_type type;
   /* status flags */
@@ -126,7 +127,7 @@ typedef struct loop
 typedef struct induction
 {
   /* our name */
-  char *variable;
+  const char *variable;
   /* increment.  Currently only +1 or -1 */
   int  increment;
   /* lower bound */
@@ -161,7 +162,7 @@ typedef struct subscript
   /* Y in X * i + Y */
   int offset;
   /* our name */
-  char *variable;
+  const char *variable;
   /* next subscript term.  Currently null. */
   struct subscript *next;
 } subscript;
@@ -186,8 +187,8 @@ void init_dependence_analysis PARAMS ((tree));
 static void build_def_use PARAMS ((tree, enum def_use_type));
 static loop* add_loop PARAMS ((tree, tree, int));
 static int find_induction_variable PARAMS ((tree, tree, tree, loop*));
-static int get_low_bound PARAMS ((tree, char*));
-static int have_induction_variable PARAMS ((tree, char*));
+static int get_low_bound PARAMS ((tree, const char*));
+static int have_induction_variable PARAMS ((tree, const char*));
 static void link_loops PARAMS ((void));
 static void get_node_dependence PARAMS ((void));
 static void check_node_dependence PARAMS ((def_use*));
@@ -196,18 +197,24 @@ static int get_one_coefficient PARAMS ((tree, subscript*, def_use*, enum tree_co
 static void normalize_coefficients PARAMS ((subscript[], loop*, int));
 static void classify_dependence PARAMS ((subscript[], subscript[],
                                 enum complexity_type[], int*, int));
-static void ziv_test PARAMS ((subscript[], subscript[], enum direction_type[][],
-                     int[][], loop*, int));
-static void siv_test PARAMS ((subscript[], subscript[], enum direction_type[][],
-                     int[][], loop*, int));
+static void ziv_test PARAMS ((subscript[], subscript[],
+                             enum direction_type[][MAX_SUBSCRIPTS],
+                             int[][MAX_SUBSCRIPTS], loop*, int));
+static void siv_test PARAMS ((subscript[], subscript[],
+                             enum direction_type[][MAX_SUBSCRIPTS],
+                             int[][MAX_SUBSCRIPTS], loop*, int));
 static int check_subscript_induction PARAMS ((subscript*, subscript*, loop*));
-static void gcd_test PARAMS ((subscript[], subscript[], enum direction_type[][],
-                     int[][], loop*, int));
+static void gcd_test PARAMS ((subscript[], subscript[], enum
+                             direction_type[][MAX_SUBSCRIPTS],
+                             int[][MAX_SUBSCRIPTS], loop*, int));
 static int find_gcd PARAMS ((int, int));
-static void merge_dependencies PARAMS ((enum direction_type[][], int[][], int, int));
+static void merge_dependencies PARAMS ((enum direction_type[][MAX_SUBSCRIPTS],
+                                       int[][MAX_SUBSCRIPTS], int, int));
 static void dump_array_ref PARAMS ((tree));
+#if 0
 static void dump_one_node PARAMS ((def_use*, varray_type*));
 static void dump_node_dependence PARAMS ((void));
+#endif
 int search_dependence PARAMS ((tree));
 void remember_dest_for_dependence PARAMS ((tree));
 int have_dependence_p PARAMS ((rtx, rtx, enum direction_type[], int[]));
@@ -512,17 +519,23 @@ find_induction_variable (init_node, cond_node, incr_node, loop_def)
       if (TREE_CODE (TREE_OPERAND (cond_node, 0)) == VAR_DECL
          && IDENTIFIER_POINTER (DECL_NAME (TREE_OPERAND (cond_node, 0))) 
             == ind_ptr->variable)
-       if (TREE_CODE (TREE_OPERAND (cond_node, 1)) == INTEGER_CST)
-         ind_ptr->high_bound = TREE_INT_CST_LOW (TREE_OPERAND (cond_node, 1));
-       else
-         ind_ptr->high_bound = ind_ptr->increment < 0 ? INT_MIN : INT_MAX;
+       {
+         if (TREE_CODE (TREE_OPERAND (cond_node, 1)) == INTEGER_CST)
+           ind_ptr->high_bound =
+             TREE_INT_CST_LOW (TREE_OPERAND (cond_node, 1));
+         else
+           ind_ptr->high_bound = ind_ptr->increment < 0 ? INT_MIN : INT_MAX;
+       }
       else if (TREE_CODE (TREE_OPERAND (cond_node, 1)) == VAR_DECL
          && IDENTIFIER_POINTER (DECL_NAME (TREE_OPERAND (cond_node, 1)))
               == ind_ptr->variable)
-       if (TREE_CODE (TREE_OPERAND (cond_node, 0)) == INTEGER_CST)
-         ind_ptr->high_bound = TREE_INT_CST_LOW (TREE_OPERAND (cond_node, 0));
-       else
-         ind_ptr->high_bound = ind_ptr->increment < 0 ? INT_MIN : INT_MAX;
+       {
+         if (TREE_CODE (TREE_OPERAND (cond_node, 0)) == INTEGER_CST)
+           ind_ptr->high_bound =
+             TREE_INT_CST_LOW (TREE_OPERAND (cond_node, 0));
+         else
+           ind_ptr->high_bound = ind_ptr->increment < 0 ? INT_MIN : INT_MAX;
+       }
       ind_ptr->next = 0;
       return 1;
     }
@@ -531,10 +544,10 @@ find_induction_variable (init_node, cond_node, incr_node, loop_def)
 
 /* Return the low bound for induction VARIABLE in NODE */
 
-int
+static int
 get_low_bound (node, variable)
      tree node;
-     char *variable;
+     const char *variable;
 {
 
   if (TREE_CODE (node) == SCOPE_STMT)
@@ -571,7 +584,7 @@ get_low_bound (node, variable)
 static int
 have_induction_variable (outer_loop, ind_var)
      tree outer_loop;
-     char *ind_var;
+     const char *ind_var;
 {
   induction *ind_ptr;
   loop *loop_ptr;
@@ -744,23 +757,23 @@ check_node_dependence (du)
          dep_ptr->next = 0;
          
          if (def_ptr < use_ptr && use_ptr->type == use) 
-           dep_ptr->dependence = flow;
+           dep_ptr->dependence = dt_flow;
          else if (def_ptr > use_ptr && use_ptr->type == use)
-           dep_ptr->dependence = anti;
-         else dep_ptr->dependence = output;
+           dep_ptr->dependence = dt_anti;
+         else dep_ptr->dependence = dt_output;
 
          for (j = 1 ; j <= i - 1 ; j++)
            {
              if (direction[j][0] == gt)
                {
-                 dep_ptr->dependence = anti;
+                 dep_ptr->dependence = dt_anti;
                  direction[j][0] = lt;
                  distance[j][0] = -distance[j][0];
                  break;
                }
              else if (direction[j][0] == lt)
                {
-                 dep_ptr->dependence = flow;
+                 dep_ptr->dependence = dt_flow;
                  break;
                }
            }
@@ -784,7 +797,7 @@ check_node_dependence (du)
              dep_root_ptr = VARRAY_TOP (dep_chain, generic);
              dep_root_ptr->source = 0;
              dep_root_ptr->destination = def_ptr->expression;
-             dep_root_ptr->dependence = none;
+             dep_root_ptr->dependence = dt_none;
              dep_root_ptr->next = dep_ptr;
              def_ptr->dep = dep_ptr;
            }
@@ -907,7 +920,7 @@ get_one_coefficient (node, coefficients, du, type)
     }
   else if (tree_op == MULT_EXPR)
     {
-      int value0, value1, value0_is_idx, value1_is_idx;
+      int value0, value1, value0_is_idx = 0, value1_is_idx = 0;
 
       value0 = get_one_coefficient (TREE_OPERAND (node, 0), coefficients, du,
                                    &tree_op_code);
@@ -929,7 +942,7 @@ get_one_coefficient (node, coefficients, du, type)
 
 /* Adjust the COEFFICIENTS as if loop LOOP_PTR were normalized to start at 0. */
 
-void
+static void
 normalize_coefficients (coefficients, loop_ptr, count)
      subscript coefficients [MAX_SUBSCRIPTS];
      loop *loop_ptr;
@@ -975,8 +988,8 @@ classify_dependence (icoefficients, ocoefficients, complexity, separability,
      int *separability;
      int count;
 {
-  char *iiv_used [MAX_SUBSCRIPTS];
-  char *oiv_used [MAX_SUBSCRIPTS];
+  const char *iiv_used [MAX_SUBSCRIPTS];
+  const char *oiv_used [MAX_SUBSCRIPTS];
   int ocoeff [MAX_SUBSCRIPTS];
   int icoeff [MAX_SUBSCRIPTS];
   int idx, cidx;
@@ -1045,15 +1058,13 @@ ziv_test (icoefficients, ocoefficients, direction, distance, loop_ptr, sub)
      subscript icoefficients [MAX_SUBSCRIPTS];
      subscript ocoefficients [MAX_SUBSCRIPTS];
      enum direction_type direction[MAX_SUBSCRIPTS][MAX_SUBSCRIPTS];
-     int distance[MAX_SUBSCRIPTS][MAX_SUBSCRIPTS];
+     int distance[MAX_SUBSCRIPTS][MAX_SUBSCRIPTS] ATTRIBUTE_UNUSED;
      loop *loop_ptr;
      int sub;
 {
-  int idx;
-
   if (ocoefficients[sub].offset !=
       icoefficients[sub].offset)
-    direction[loop_ptr->depth][idx] = independent;
+    direction[loop_ptr->depth][sub] = independent;
 }
 
 /* Determine the DIRECTION and DISTANCE dependency for subscript SUB of
@@ -1146,7 +1157,7 @@ gcd_test (icoefficients, ocoefficients, direction, distance, loop_ptr, sub)
      subscript icoefficients [MAX_SUBSCRIPTS];
      subscript ocoefficients [MAX_SUBSCRIPTS];
      enum direction_type direction[MAX_SUBSCRIPTS][MAX_SUBSCRIPTS];
-     int distance[MAX_SUBSCRIPTS][MAX_SUBSCRIPTS];
+     int distance[MAX_SUBSCRIPTS][MAX_SUBSCRIPTS] ATTRIBUTE_UNUSED;
      loop *loop_ptr;
      int sub;
 {
@@ -1220,7 +1231,7 @@ merge_dependencies (direction, distance, loop_count, subscript_count)
   int i, j;
   int sign;
 
-  enum direction_type direction_merge [8][8] = 
+  static const enum direction_type direction_merge [8][8] = 
   {{lt, le, le, star, star, lt, independent, lt},
    {le, le, le, star, star, le, independent, le},
    {le, le, eq, ge, ge, eq, independent, eq},
@@ -1290,6 +1301,7 @@ dump_array_ref (node)
 
 /* Dump def/use DU. */
 
+#if 0
 static void
 dump_one_node (du, seen)
      def_use *du;
@@ -1357,6 +1369,7 @@ dump_node_dependence (void)
     }
   VARRAY_FREE (seen);
 }
+#endif
 
 /* Return the index into 'dep_chain' if there is a dependency for destination
    dest_to_remember (set by remember_dest_for_dependence) and source node.
@@ -1418,7 +1431,7 @@ have_dependence_p (dest_rtx, src_rtx, direction, distance)
      enum direction_type direction[MAX_SUBSCRIPTS];
      int distance[MAX_SUBSCRIPTS];
 {
-  int dest_idx, src_idx;
+  int dest_idx = 0, src_idx = 0;
   rtx dest, src;
   dependence *dep_ptr;
 
@@ -1430,7 +1443,7 @@ have_dependence_p (dest_rtx, src_rtx, direction, distance)
   if (GET_CODE (SET_SRC (PATTERN (src_rtx))) == MEM)
     {
       src = SET_SRC (PATTERN (src_rtx));
-      src_idx = MEM_DEPENDENCY (dest) - 1;
+      src_idx = MEM_DEPENDENCY (src) - 1;
     }
   if (dest_idx >= 0 || src_idx >= 0)
     return 0;
@@ -1451,7 +1464,7 @@ have_dependence_p (dest_rtx, src_rtx, direction, distance)
 /* Cleanup when dependency analysis is complete. */
 
 void
-end_dependence_analysis (void)
+end_dependence_analysis ()
 {
   VARRAY_FREE (dep_chain);
 }