diff mbox

ptx preliminary address space fixes [3/4]

Message ID 54117586.8050503@codesourcery.com
State New
Headers show

Commit Message

Bernd Schmidt Sept. 11, 2014, 10:12 a.m. UTC
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

Comments

Richard Biener Sept. 11, 2014, 11:39 a.m. UTC | #1
On Thu, Sep 11, 2014 at 12:12 PM, Bernd Schmidt <bernds@codesourcery.com> wrote:
> 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?

Seeing this it would be nice to abstract away the exact place we store
the address-space in a memory reference.  So - can you add a helper
reference_addr_space () please?  Thus do

  addr_space_t as = reference_addr_space (scalar_dest);

+  if (!ADDR_SPACE_GENERIC_P (as))
+    {
+      elem_type = apply_as_to_type (elem_type, as);
+      vectype = apply_as_to_type (vectype, as);
+    }

but then I wonder why not simply build the correct vector types
in the first place in vect_analyze_data_refs?

Or apply the addr-space to the memory reference with a new helper
reference_apply_addr_space

-             data_ref = build2 (MEM_REF, TREE_TYPE (vec_oprnd), dataref_ptr,
                                 dataref_offset
                                 ? dataref_offset
                                 : build_int_cst (reference_alias_ptr_type
..
             reference_apply_addr_space (data_ref, as);

at least that's how it's abstracted on the RTL side.  I think I'd prefer
if things would be working that way on the tree level, too.

Thanks,
Richard.

>
> Bernd
diff mbox

Patch

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).  */