This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

ptx preliminary address space fixes [3/4]


The vectorizer can also replace a memory reference without ensuring it uses the correct address space.

Bootstrapped and tested together with the other patches on x86_64-linux. Ok?


Bernd
commit e85dbde1aa3396b5e202aa736f96b232a6e11e86
Author: Bernd Schmidt <bernds@codesourcery.com>
Date:   Wed Sep 10 16:33:40 2014 +0200

    	* tree-vect-stmts.c (vectorizable_store, vectorizable_load): Apply
    	address spaces to the type of the MEM_REF as needed.

diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index 26eb2d4..5fca144 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -5026,6 +5026,9 @@ vectorizable_store (gimple stmt, gimple_stmt_iterator *gsi, gimple *vec_stmt,
       && TREE_CODE (scalar_dest) != MEM_REF)
     return false;
 
+  tree dest_type = TREE_TYPE (scalar_dest);
+  addr_space_t as = TYPE_ADDR_SPACE (dest_type);
+
   gcc_assert (gimple_assign_single_p (stmt));
   op = gimple_assign_rhs1 (stmt);
   if (!vect_is_simple_use (op, stmt, loop_vinfo, bb_vinfo, &def_stmt,
@@ -5038,6 +5041,11 @@ vectorizable_store (gimple stmt, gimple_stmt_iterator *gsi, gimple *vec_stmt,
     }
 
   elem_type = TREE_TYPE (vectype);
+  if (!ADDR_SPACE_GENERIC_P (as))
+    {
+      elem_type = apply_as_to_type (elem_type, as);
+      vectype = apply_as_to_type (vectype, as);
+    }
   vec_mode = TYPE_MODE (vectype);
 
   /* FORNOW. In some cases can vectorize even if data-type not supported
@@ -5379,7 +5387,7 @@ vectorizable_store (gimple stmt, gimple_stmt_iterator *gsi, gimple *vec_stmt,
 		   vect_permute_store_chain().  */
 		vec_oprnd = result_chain[i];
 
-	      data_ref = build2 (MEM_REF, TREE_TYPE (vec_oprnd), dataref_ptr,
+	      data_ref = build2 (MEM_REF, vectype, dataref_ptr,
 				 dataref_offset
 				 ? dataref_offset
 				 : build_int_cst (reference_alias_ptr_type
@@ -5692,8 +5700,17 @@ vectorizable_load (gimple stmt, gimple_stmt_iterator *gsi, gimple *vec_stmt,
   if (!STMT_VINFO_DATA_REF (stmt_info))
     return false;
 
+  tree rhs = gimple_assign_rhs1 (stmt);
+  tree rhstype = TREE_TYPE (rhs);
+  addr_space_t as = TYPE_ADDR_SPACE (rhstype);
+
   elem_type = TREE_TYPE (vectype);
   mode = TYPE_MODE (vectype);
+  if (!ADDR_SPACE_GENERIC_P (as))
+    {
+      elem_type = apply_as_to_type (elem_type, as);
+      vectype = apply_as_to_type (vectype, as);
+    }
 
   /* FORNOW. In some cases can vectorize even if data-type not supported
     (e.g. - data copies).  */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]