OSDN Git Service

2005-06-01 Daniel Berlin <dberlin@dberlin.org>
[pf3gnuchains/gcc-fork.git] / gcc / tree-vect-analyze.c
index 71f7663..4d2058f 100644 (file)
@@ -23,7 +23,6 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include "system.h"
 #include "coretypes.h"
 #include "tm.h"
-#include "errors.h"
 #include "ggc.h"
 #include "tree.h"
 #include "basic-block.h"
@@ -1076,13 +1075,6 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo)
   struct data_reference *dr0 = NULL;
   unsigned int i, j;
 
-  /* Sigh, a hack to make targets that do not define UNITS_PER_SIMD_WORD
-     bootstrap.  Copy UNITS_PER_SIMD_WORD to a local variable to avoid a
-     "division by zero" error.  This error would be issued because we
-     we do "... % UNITS_PER_SIMD_WORD" below, and UNITS_PER_SIMD_WORD
-     defaults to 0 if it is not defined by the target.  */
-  int units_per_simd_word = UNITS_PER_SIMD_WORD;
-
   /*
      This pass will require a cost model to guide it whether to apply peeling 
      or versioning or a combination of the two. For example, the scheme that
@@ -1237,7 +1229,7 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo)
                  int drsize = GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (DR_REF (dr))));
 
                  DR_MISALIGNMENT (dr) += npeel * drsize;
-                 DR_MISALIGNMENT (dr) %= units_per_simd_word;
+                 DR_MISALIGNMENT (dr) %= UNITS_PER_SIMD_WORD;
                }
              else
                DR_MISALIGNMENT (dr) = -1;
@@ -1253,7 +1245,7 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo)
 /* Function vect_analyze_data_refs_alignment
 
    Analyze the alignment of the data-references in the loop.
-   FOR NOW: Until support for misliagned accesses is in place, only if all
+   FOR NOW: Until support for misaligned accesses is in place, only if all
    accesses are aligned can the loop be vectorized. This restriction will be 
    relaxed.  */ 
 
@@ -1915,7 +1907,7 @@ vect_object_analysis (tree memref, tree stmt, bool is_read,
           foreach ref
             base_address = vect_object_analysis(ref)
       1.1- vect_object_analysis(ref): 
-           Analyze ref, and build a DR (data_referece struct) for it;
+           Analyze ref, and build a DR (data_reference struct) for it;
            compute base, initial_offset, step and alignment. 
            Call get_inner_reference for refs handled in this function.
            Call vect_addr_analysis(addr) to analyze pointer type expressions.
@@ -1950,29 +1942,25 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo)
          bool is_read = false;
          tree stmt = bsi_stmt (si);
          stmt_vec_info stmt_info = vinfo_for_stmt (stmt);
-         v_may_def_optype v_may_defs = STMT_V_MAY_DEF_OPS (stmt);
-         v_must_def_optype v_must_defs = STMT_V_MUST_DEF_OPS (stmt);
-         vuse_optype vuses = STMT_VUSE_OPS (stmt);
          varray_type *datarefs = NULL;
-         int nvuses, nv_may_defs, nv_must_defs;
          tree memref = NULL;
          tree scalar_type, vectype;      
          tree base, offset, misalign, step, tag;
          struct ptr_info_def *ptr_info;
          bool base_aligned;
          subvar_t subvars = NULL;
+         bool no_vuse, no_vmaymust;
 
          /* Assumption: there exists a data-ref in stmt, if and only if 
              it has vuses/vdefs.  */
 
-         if (!vuses && !v_may_defs && !v_must_defs)
+         no_vuse = ZERO_SSA_OPERANDS (stmt, SSA_OP_VUSE);
+         no_vmaymust = ZERO_SSA_OPERANDS (stmt,
+                                          SSA_OP_VMAYDEF | SSA_OP_VMUSTDEF);
+         if (no_vuse && no_vmaymust)
            continue;
 
-         nvuses = NUM_VUSES (vuses);
-         nv_may_defs = NUM_V_MAY_DEFS (v_may_defs);
-         nv_must_defs = NUM_V_MUST_DEFS (v_must_defs);
-
-         if (nvuses && (nv_may_defs || nv_must_defs))
+         if (!no_vuse && !no_vmaymust)
            {
              if (vect_print_dump_info (REPORT_DETAILS, UNKNOWN_LOC))
                {
@@ -1992,7 +1980,7 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo)
              return false;
            }
 
-         if (vuses)
+         if (!no_vuse)
            {
              memref = TREE_OPERAND (stmt, 1);
              datarefs = &(LOOP_VINFO_DATAREF_READS (loop_vinfo));
@@ -2113,49 +2101,29 @@ vect_mark_relevant (VEC(tree,heap) **worklist, tree stmt)
 static bool
 vect_stmt_relevant_p (tree stmt, loop_vec_info loop_vinfo)
 {
-  v_may_def_optype v_may_defs;
-  v_must_def_optype v_must_defs;
   struct loop *loop = LOOP_VINFO_LOOP (loop_vinfo);
   ssa_op_iter op_iter;
   imm_use_iterator imm_iter;
   use_operand_p use_p;
-  tree var;
+  def_operand_p def_p;
 
   /* cond stmt other than loop exit cond.  */
   if (is_ctrl_stmt (stmt) && (stmt != LOOP_VINFO_EXIT_COND (loop_vinfo)))
     return true;
 
   /* changing memory.  */
-  if (TREE_CODE (stmt) == PHI_NODE)
-    {
-      if (!is_gimple_reg (PHI_RESULT (stmt)))
-        return false;
-      FOR_EACH_IMM_USE_FAST (use_p, imm_iter, PHI_RESULT (stmt))
-       {
-         basic_block bb = bb_for_stmt (USE_STMT (use_p));
-         if (!flow_bb_inside_loop_p (loop, bb))
-           {
-             if (vect_print_dump_info (REPORT_DETAILS, UNKNOWN_LOC))
-               fprintf (vect_dump, "vec_stmt_relevant_p: used out of loop.");
-             return true;
-           }
-       }
-      return false;
-    }
-
-  v_may_defs = STMT_V_MAY_DEF_OPS (stmt);
-  v_must_defs = STMT_V_MUST_DEF_OPS (stmt);
-  if (v_may_defs || v_must_defs)
-    {
-      if (vect_print_dump_info (REPORT_DETAILS, UNKNOWN_LOC))
-       fprintf (vect_dump, "vec_stmt_relevant_p: stmt has vdefs.");
-      return true;
-    }
+  if (TREE_CODE (stmt) != PHI_NODE)
+    if (!ZERO_SSA_OPERANDS (stmt, SSA_OP_VIRTUAL_DEFS))
+      {
+       if (vect_print_dump_info (REPORT_DETAILS, UNKNOWN_LOC))
+         fprintf (vect_dump, "vec_stmt_relevant_p: stmt has vdefs.");
+       return true;
+      }
 
   /* uses outside the loop.  */
-  FOR_EACH_SSA_TREE_OPERAND (var, stmt, op_iter, SSA_OP_DEF)
+  FOR_EACH_PHI_OR_STMT_DEF (def_p, stmt, op_iter, SSA_OP_DEF)
     {
-      FOR_EACH_IMM_USE_FAST (use_p, imm_iter, var)
+      FOR_EACH_IMM_USE_FAST (use_p, imm_iter, DEF_FROM_PTR (def_p))
        {
          basic_block bb = bb_for_stmt (USE_STMT (use_p));
          if (!flow_bb_inside_loop_p (loop, bb))
@@ -2195,11 +2163,10 @@ vect_mark_stmts_to_be_vectorized (loop_vec_info loop_vinfo)
   basic_block *bbs = LOOP_VINFO_BBS (loop_vinfo);
   unsigned int nbbs = loop->num_nodes;
   block_stmt_iterator si;
-  tree stmt;
-  stmt_ann_t ann;
+  tree stmt, use;
+  ssa_op_iter iter;
   unsigned int i;
   int j;
-  use_optype use_ops;
   stmt_vec_info stmt_info;
   basic_block bb;
   tree phi;
@@ -2298,12 +2265,8 @@ vect_mark_stmts_to_be_vectorized (loop_vec_info loop_vinfo)
            }
        } 
 
-      ann = stmt_ann (stmt);
-      use_ops = USE_OPS (ann);
-
-      for (i = 0; i < NUM_USES (use_ops); i++)
+      FOR_EACH_SSA_TREE_OPERAND (use, stmt, iter, SSA_OP_USE)
        {
-         tree use = USE_OP (use_ops, i);
 
          /* We are only interested in uses that need to be vectorized. Uses 
             that are used for address computation are not considered relevant.
@@ -2502,7 +2465,7 @@ vect_analyze_loop_form (struct loop *loop)
   if (!empty_block_p (loop->latch))
     {
       if (vect_print_dump_info (REPORT_BAD_FORM_LOOPS, loop_loc))
-        fprintf (vect_dump, "not vectorized: unexpectd loop form.");
+        fprintf (vect_dump, "not vectorized: unexpected loop form.");
       return NULL;
     }