tree-vect-loop-manip.c (vect_create_cond_for_alias_checks): Remove cond_expr_stmt_lis...
authorRichard Biener <rguenther@suse.de>
Mon, 18 Mar 2013 13:57:33 +0000 (13:57 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 18 Mar 2013 13:57:33 +0000 (13:57 +0000)
2013-03-18  Richard Biener  <rguenther@suse.de>

* tree-vect-loop-manip.c (vect_create_cond_for_alias_checks):
Remove cond_expr_stmt_list argument and do not gimplify the
built expression.
(vect_loop_versioning): Adjust.
* tree-vect-data-refs.c (vect_create_addr_base_for_vector_ref):
Cleanup to use less temporaries.
(vect_create_data_ref_ptr): Cleanup.

From-SVN: r196782

gcc/ChangeLog
gcc/tree-vect-data-refs.c
gcc/tree-vect-loop-manip.c

index de91c80b3f78e8ab19500753869918ee4b273a05..7cdca5fc88ace06f02576d8b64e44bff5cda3251 100644 (file)
@@ -1,3 +1,13 @@
+2013-03-18  Richard Biener  <rguenther@suse.de>
+
+       * tree-vect-loop-manip.c (vect_create_cond_for_alias_checks):
+       Remove cond_expr_stmt_list argument and do not gimplify the
+       built expression.
+       (vect_loop_versioning): Adjust.
+       * tree-vect-data-refs.c (vect_create_addr_base_for_vector_ref):
+       Cleanup to use less temporaries.
+       (vect_create_data_ref_ptr): Cleanup.
+
 2013-03-18  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/56635
index 49216f4c67043d47d203fb57c5e9d3bf8ca5a1e5..a4ad4f754a883de65556e14e06d0ecc503fb4dba 100644 (file)
@@ -3470,19 +3470,16 @@ vect_create_addr_base_for_vector_ref (gimple stmt,
 {
   stmt_vec_info stmt_info = vinfo_for_stmt (stmt);
   struct data_reference *dr = STMT_VINFO_DATA_REF (stmt_info);
-  tree data_ref_base = unshare_expr (DR_BASE_ADDRESS (dr));
+  tree data_ref_base;
   const char *base_name;
-  tree data_ref_base_var;
-  tree vec_stmt;
-  tree addr_base, addr_expr;
+  tree addr_base;
   tree dest;
   gimple_seq seq = NULL;
-  tree base_offset = unshare_expr (DR_OFFSET (dr));
-  tree init = unshare_expr (DR_INIT (dr));
+  tree base_offset;
+  tree init;
   tree vect_ptr_type;
   tree step = TYPE_SIZE_UNIT (TREE_TYPE (DR_REF (dr)));
   loop_vec_info loop_vinfo = STMT_VINFO_LOOP_VINFO (stmt_info);
-  tree base;
 
   if (loop_vinfo && loop && loop != (gimple_bb (stmt))->loop_father)
     {
@@ -3494,6 +3491,12 @@ vect_create_addr_base_for_vector_ref (gimple stmt,
       base_offset = unshare_expr (STMT_VINFO_DR_OFFSET (stmt_info));
       init = unshare_expr (STMT_VINFO_DR_INIT (stmt_info));
     }
+  else
+    {
+      data_ref_base = unshare_expr (DR_BASE_ADDRESS (dr));
+      base_offset = unshare_expr (DR_OFFSET (dr));
+      init = unshare_expr (DR_INIT (dr));
+    }
 
   if (loop_vinfo)
     base_name = get_name (data_ref_base);
@@ -3504,29 +3507,17 @@ vect_create_addr_base_for_vector_ref (gimple stmt,
       base_name = get_name (DR_REF (dr));
     }
 
-  data_ref_base_var = create_tmp_var (TREE_TYPE (data_ref_base), "batmp");
-  data_ref_base = force_gimple_operand (data_ref_base, &seq, true,
-                                       data_ref_base_var);
-  gimple_seq_add_seq (new_stmt_list, seq);
-
   /* Create base_offset */
   base_offset = size_binop (PLUS_EXPR,
                            fold_convert (sizetype, base_offset),
                            fold_convert (sizetype, init));
-  dest = create_tmp_var (sizetype, "base_off");
-  base_offset = force_gimple_operand (base_offset, &seq, true, dest);
-  gimple_seq_add_seq (new_stmt_list, seq);
 
   if (offset)
     {
-      tree tmp = create_tmp_var (sizetype, "offset");
-
       offset = fold_build2 (MULT_EXPR, sizetype,
                            fold_convert (sizetype, offset), step);
       base_offset = fold_build2 (PLUS_EXPR, sizetype,
                                 base_offset, offset);
-      base_offset = force_gimple_operand (base_offset, &seq, false, tmp);
-      gimple_seq_add_seq (new_stmt_list, seq);
     }
 
   /* base + base_offset */
@@ -3540,34 +3531,26 @@ vect_create_addr_base_for_vector_ref (gimple stmt,
     }
 
   vect_ptr_type = build_pointer_type (STMT_VINFO_VECTYPE (stmt_info));
-  base = get_base_address (DR_REF (dr));
-  if (base
-      && TREE_CODE (base) == MEM_REF)
-    vect_ptr_type
-      = build_qualified_type (vect_ptr_type,
-                             TYPE_QUALS (TREE_TYPE (TREE_OPERAND (base, 0))));
-
-  vec_stmt = fold_convert (vect_ptr_type, addr_base);
-  addr_expr = vect_get_new_vect_var (vect_ptr_type, vect_pointer_var,
-                                     base_name);
-  vec_stmt = force_gimple_operand (vec_stmt, &seq, false, addr_expr);
+  addr_base = fold_convert (vect_ptr_type, addr_base);
+  dest = vect_get_new_vect_var (vect_ptr_type, vect_pointer_var, base_name);
+  addr_base = force_gimple_operand (addr_base, &seq, false, dest);
   gimple_seq_add_seq (new_stmt_list, seq);
 
   if (DR_PTR_INFO (dr)
-      && TREE_CODE (vec_stmt) == SSA_NAME)
+      && TREE_CODE (addr_base) == SSA_NAME)
     {
-      duplicate_ssa_name_ptr_info (vec_stmt, DR_PTR_INFO (dr));
+      duplicate_ssa_name_ptr_info (addr_base, DR_PTR_INFO (dr));
       if (offset)
-       mark_ptr_info_alignment_unknown (SSA_NAME_PTR_INFO (vec_stmt));
+       mark_ptr_info_alignment_unknown (SSA_NAME_PTR_INFO (addr_base));
     }
 
   if (dump_enabled_p ())
     {
       dump_printf_loc (MSG_NOTE, vect_location, "created ");
-      dump_generic_expr (MSG_NOTE, TDF_SLIM, vec_stmt);
+      dump_generic_expr (MSG_NOTE, TDF_SLIM, addr_base);
     }
 
-  return vec_stmt;
+  return addr_base;
 }
 
 
@@ -3647,7 +3630,6 @@ vect_create_data_ref_ptr (gimple stmt, tree aggr_type, struct loop *at_loop,
   gimple incr;
   tree step;
   bb_vec_info bb_vinfo = STMT_VINFO_BB_VINFO (stmt_info);
-  tree base;
 
   gcc_assert (TREE_CODE (aggr_type) == ARRAY_TYPE
              || TREE_CODE (aggr_type) == VECTOR_TYPE);
@@ -3699,53 +3681,37 @@ vect_create_data_ref_ptr (gimple stmt, tree aggr_type, struct loop *at_loop,
       dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_BASE_OBJECT (dr));
     }
 
-  /* (1) Create the new aggregate-pointer variable.  */
-  aggr_ptr_type = build_pointer_type (aggr_type);
-  base = get_base_address (DR_REF (dr));
-  if (base
-      && TREE_CODE (base) == MEM_REF)
-    aggr_ptr_type
-      = build_qualified_type (aggr_ptr_type,
-                             TYPE_QUALS (TREE_TYPE (TREE_OPERAND (base, 0))));
-  aggr_ptr = vect_get_new_vect_var (aggr_ptr_type, vect_pointer_var, base_name);
-
-  /* Vector and array types inherit the alias set of their component
+  /* (1) Create the new aggregate-pointer variable.
+     Vector and array types inherit the alias set of their component
      type by default so we need to use a ref-all pointer if the data
      reference does not conflict with the created aggregated data
      reference because it is not addressable.  */
-  if (!alias_sets_conflict_p (get_deref_alias_set (aggr_ptr),
+  bool need_ref_all = false;
+  if (!alias_sets_conflict_p (get_alias_set (aggr_type),
                              get_alias_set (DR_REF (dr))))
-    {
-      aggr_ptr_type
-       = build_pointer_type_for_mode (aggr_type,
-                                      TYPE_MODE (aggr_ptr_type), true);
-      aggr_ptr = vect_get_new_vect_var (aggr_ptr_type, vect_pointer_var,
-                                       base_name);
-    }
-
+    need_ref_all = true;
   /* Likewise for any of the data references in the stmt group.  */
   else if (STMT_VINFO_GROUP_SIZE (stmt_info) > 1)
     {
       gimple orig_stmt = STMT_VINFO_GROUP_FIRST_ELEMENT (stmt_info);
       do
        {
-         tree lhs = gimple_assign_lhs (orig_stmt);
-         if (!alias_sets_conflict_p (get_deref_alias_set (aggr_ptr),
-                                     get_alias_set (lhs)))
+         stmt_vec_info sinfo = vinfo_for_stmt (orig_stmt);
+         struct data_reference *sdr = STMT_VINFO_DATA_REF (sinfo);
+         if (!alias_sets_conflict_p (get_alias_set (aggr_type),
+                                     get_alias_set (DR_REF (sdr))))
            {
-             aggr_ptr_type
-               = build_pointer_type_for_mode (aggr_type,
-                                              TYPE_MODE (aggr_ptr_type), true);
-             aggr_ptr
-               = vect_get_new_vect_var (aggr_ptr_type, vect_pointer_var,
-                                        base_name);
+             need_ref_all = true;
              break;
            }
-
-         orig_stmt = STMT_VINFO_GROUP_NEXT_ELEMENT (vinfo_for_stmt (orig_stmt));
+         orig_stmt = STMT_VINFO_GROUP_NEXT_ELEMENT (sinfo);
        }
       while (orig_stmt);
     }
+  aggr_ptr_type = build_pointer_type_for_mode (aggr_type, ptr_mode,
+                                              need_ref_all);
+  aggr_ptr = vect_get_new_vect_var (aggr_ptr_type, vect_pointer_var, base_name);
+
 
   /* Note: If the dataref is in an inner-loop nested in LOOP, and we are
      vectorizing LOOP (i.e., outer-loop vectorization), we need to create two
index 559f6e9e9979882c641ebb183f911214ffaf2828..ff7d53f25914e30688efbd15bfcd11c890a8072b 100644 (file)
@@ -2271,20 +2271,14 @@ vect_vfa_segment_size (struct data_reference *dr, tree length_factor)
 
    Output:
    COND_EXPR - conditional expression.
-   COND_EXPR_STMT_LIST - statements needed to construct the conditional
-                         expression.
-
 
    The returned value is the conditional expression to be used in the if
    statement that controls which version of the loop gets executed at runtime.
 */
 
 static void
-vect_create_cond_for_alias_checks (loop_vec_info loop_vinfo,
-                                  tree * cond_expr,
-                                  gimple_seq * cond_expr_stmt_list)
+vect_create_cond_for_alias_checks (loop_vec_info loop_vinfo, tree * cond_expr)
 {
-  struct loop *loop = LOOP_VINFO_LOOP (loop_vinfo);
   vec<ddr_p>  may_alias_ddrs =
     LOOP_VINFO_MAY_ALIAS_DDRS (loop_vinfo);
   int vect_factor = LOOP_VINFO_VECT_FACTOR (loop_vinfo);
@@ -2333,12 +2327,14 @@ vect_create_cond_for_alias_checks (loop_vec_info loop_vinfo,
          dr_b = STMT_VINFO_DATA_REF (vinfo_for_stmt (stmt_b));
        }
 
-      addr_base_a =
-        vect_create_addr_base_for_vector_ref (stmt_a, cond_expr_stmt_list,
-                                             NULL_TREE, loop);
-      addr_base_b =
-        vect_create_addr_base_for_vector_ref (stmt_b, cond_expr_stmt_list,
-                                             NULL_TREE, loop);
+      addr_base_a
+       = fold_build_pointer_plus (DR_BASE_ADDRESS (dr_a),
+                                  size_binop (PLUS_EXPR, DR_OFFSET (dr_a),
+                                              DR_INIT (dr_a)));
+      addr_base_b
+       = fold_build_pointer_plus (DR_BASE_ADDRESS (dr_b),
+                                  size_binop (PLUS_EXPR, DR_OFFSET (dr_b),
+                                              DR_INIT (dr_b)));
 
       if (!operand_equal_p (DR_STEP (dr_a), DR_STEP (dr_b), 0))
        length_factor = scalar_loop_iters;
@@ -2435,8 +2431,7 @@ vect_loop_versioning (loop_vec_info loop_vinfo,
                                       &cond_expr_stmt_list);
 
   if (LOOP_REQUIRES_VERSIONING_FOR_ALIAS (loop_vinfo))
-    vect_create_cond_for_alias_checks (loop_vinfo, &cond_expr,
-                                      &cond_expr_stmt_list);
+    vect_create_cond_for_alias_checks (loop_vinfo, &cond_expr);
 
   cond_expr = force_gimple_operand_1 (cond_expr, &gimplify_stmt_list,
                                      is_gimple_condexpr, NULL_TREE);