tree-vectorizer.c (vect_analyze_offset_expr): Use expr_invariant_in_loop_p.
authorIra Rosen <irar@il.ibm.com>
Sun, 9 Jan 2005 15:12:36 +0000 (15:12 +0000)
committerDorit Nuzman <dorit@gcc.gnu.org>
Sun, 9 Jan 2005 15:12:36 +0000 (15:12 +0000)
2005-01-09  Ira Rosen  <irar@il.ibm.com>

        * tree-vectorizer.c (vect_analyze_offset_expr): Use
        expr_invariant_in_loop_p.
        Initialize outputs first thing in the function.
        (vect_update_ivs_after_vectorizer): Call initial_condition_in_loop_num.
        (vect_is_simple_iv_evolution): Call initial_condition_in_loop_num.
        (vect_analyze_pointer_ref_access): Check that the initial condition of
        the access function is loop invariant.

From-SVN: r93113

gcc/ChangeLog
gcc/tree-vectorizer.c

index 31d29e4f68f1c61fe2e3e7d9d3fcfe31782feb69..3d39d220579cdf5fdbd8dcb4805bced112ed3ebc 100644 (file)
@@ -1,3 +1,13 @@
+2005-01-09  Ira Rosen  <irar@il.ibm.com>
+
+       * tree-vectorizer.c (vect_analyze_offset_expr): Use 
+       expr_invariant_in_loop_p.
+       Initialize outputs first thing in the function.
+       (vect_update_ivs_after_vectorizer): Call initial_condition_in_loop_num.
+       (vect_is_simple_iv_evolution): Call initial_condition_in_loop_num.
+       (vect_analyze_pointer_ref_access): Check that the initial condition of 
+       the access function is loop invariant.
+
 2005-01-09  Richard Henderson  <rth@redhat.com>
 
        * config/i386/i386.c (bdesc_2arg): Update names for mmx_ prefixes.
index fe85dddaa0b35c504a3329efb97fc6c16c0fcd42..62767edd3f9f3324ed37ef53e6f816f9a6ec3004 100644 (file)
@@ -1415,17 +1415,17 @@ vect_analyze_offset_expr (tree expr,
   tree left_step = size_zero_node;
   tree right_step = size_zero_node;
   enum tree_code code;
-  tree init, evolution, def_stmt;
+  tree init, evolution;
+
+  *step = NULL_TREE;
+  *misalign = NULL_TREE;
+  *initial_offset = NULL_TREE;
 
   /* Strip conversions that don't narrow the mode.  */
   expr = vect_strip_conversion (expr);
   if (!expr)
     return false;
 
-  *step = NULL_TREE;
-  *misalign = NULL_TREE;
-  *initial_offset = NULL_TREE;
-
   /* Stop conditions:
      1. Constant.  */
   if (TREE_CODE (expr) == INTEGER_CST)
@@ -1447,18 +1447,12 @@ vect_analyze_offset_expr (tree expr,
        return false;
 
       init = initial_condition_in_loop_num (access_fn, loop->num);
-      if (init == expr)
-       {
-         def_stmt = SSA_NAME_DEF_STMT (init);
-         if (def_stmt 
-             && !IS_EMPTY_STMT (def_stmt)
-             && flow_bb_inside_loop_p (loop, bb_for_stmt (def_stmt)))
-           /* Not enough information: may be not loop invariant.  
-              E.g., for a[b[i]], we get a[D], where D=b[i]. EXPR is D, its 
-              initial_condition is D, but it depends on i - loop's induction
-              variable.  */      
-           return false;
-       }
+      if (init == expr && !expr_invariant_in_loop_p (loop, init))
+       /* Not enough information: may be not loop invariant.  
+          E.g., for a[b[i]], we get a[D], where D=b[i]. EXPR is D, its 
+          initial_condition is D, but it depends on i - loop's induction
+          variable.  */          
+       return false;
 
       evolution = evolution_part_in_loop_num (access_fn, loop->num);
       if (evolution && TREE_CODE (evolution) != INTEGER_CST)
@@ -3174,7 +3168,8 @@ vect_update_ivs_after_vectorizer (struct loop *loop, tree niters, edge update_e)
       gcc_assert (!tree_is_chrec (evolution_part));
 
       step_expr = evolution_part;
-      init_expr = unshare_expr (initial_condition (access_fn));
+      init_expr = unshare_expr (initial_condition_in_loop_num (access_fn, 
+                                                              loop->num));
 
       ni = build2 (PLUS_EXPR, TREE_TYPE (init_expr),
                  build2 (MULT_EXPR, TREE_TYPE (niters),
@@ -3890,7 +3885,7 @@ vect_is_simple_iv_evolution (unsigned loop_nb, tree access_fn, tree * init,
     return false;
   
   step_expr = evolution_part;
-  init_expr = unshare_expr (initial_condition (access_fn));
+  init_expr = unshare_expr (initial_condition_in_loop_num (access_fn, loop_nb));
 
   if (vect_debug_details (NULL))
     {
@@ -4618,6 +4613,14 @@ vect_analyze_pointer_ref_access (tree memref, tree stmt, bool is_read)
                
   STRIP_NOPS (init);
 
+  if (!expr_invariant_in_loop_p (loop, init))
+    {
+      if (vect_debug_stats (loop) || vect_debug_details (loop)) 
+       fprintf (dump_file, 
+                "not vectorized: initial condition is not loop invariant.");   
+      return NULL;
+    }
+
   if (TREE_CODE (step) != INTEGER_CST)
     {
       if (vect_debug_stats (loop) || vect_debug_details (loop))