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]

[PATCH][RFC] A fix for PR37955, recompute aliasing after vectorization, use ref-all pointer as fallback


This fixes PR37955.  Finally we recompute alias information after
vectorization (because we may end up creating a pointer kind we
do not have computed flow insensitive alias information yet).
Instead of asserting that we never hit the situation that the
vectorized stmts do not conflict with the scalar stmts from an
aliasing perspective (which they certainly should - otherwise we
just have generated wrong code), we fixup the pointer used for the
access to be a ref-all pointer which will always conflict with
the original statement.

Of course the ref-all fixup is quite a hack at the place I put it.
I will see if I can find a more suitable place ...

Bootstrapped and tested on x86_64-unknown-linux-gnu.

Comments / tests appreciated.

Thanks,
Richard.

2008-11-07  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/37955
	* tree-vectorizer.c (vectorize_loops): Run TODO_rebuild_alias.
	* tree-vect-transform.c (vect_create_data_ref_ptr): Do not
	merge alias info.
	(bump_vector_ptr): Likewise.
	(vectorizable_store): Use a ref-all pointer if the vectorized
	stmt doesn't conflict with the original one.
	(vectorizable_load): Likewise.

	* gcc.c-torture/compile/pr37955.c: New testcase.

Index: gcc/tree-vectorizer.c
===================================================================
*** gcc/tree-vectorizer.c	(revision 141641)
--- gcc/tree-vectorizer.c	(working copy)
*************** vectorize_loops (void)
*** 2847,2853 ****
  
    free_stmt_vec_info_vec ();
  
!   return num_vectorized_loops > 0 ? TODO_cleanup_cfg : 0;
  }
  
  /* Increase alignment of global arrays to improve vectorization potential.
--- 2847,2853 ----
  
    free_stmt_vec_info_vec ();
  
!   return num_vectorized_loops > 0 ? TODO_cleanup_cfg | TODO_rebuild_alias : 0;
  }
  
  /* Increase alignment of global arrays to improve vectorization potential.
Index: gcc/tree-vect-transform.c
===================================================================
*** gcc/tree-vect-transform.c	(revision 141641)
--- gcc/tree-vect-transform.c	(working copy)
*************** vect_create_data_ref_ptr (gimple stmt, s
*** 1197,1204 ****
  	  duplicate_ssa_name_ptr_info (indx_before_incr, DR_PTR_INFO (dr));
  	  duplicate_ssa_name_ptr_info (indx_after_incr, DR_PTR_INFO (dr));
  	}
-       merge_alias_info (vect_ptr_init, indx_before_incr);
-       merge_alias_info (vect_ptr_init, indx_after_incr);
        if (ptr_incr)
  	*ptr_incr = incr;
  
--- 1197,1202 ----
*************** vect_create_data_ref_ptr (gimple stmt, s
*** 1229,1236 ****
  	  duplicate_ssa_name_ptr_info (indx_before_incr, DR_PTR_INFO (dr));
  	  duplicate_ssa_name_ptr_info (indx_after_incr, DR_PTR_INFO (dr));
  	}
-       merge_alias_info (vect_ptr_init, indx_before_incr);
-       merge_alias_info (vect_ptr_init, indx_after_incr);
        if (ptr_incr)
  	*ptr_incr = incr;
  
--- 1227,1232 ----
*************** bump_vector_ptr (tree dataref_ptr, gimpl
*** 1301,1307 ****
    /* Copy the points-to information if it exists. */
    if (DR_PTR_INFO (dr))
      duplicate_ssa_name_ptr_info (new_dataref_ptr, DR_PTR_INFO (dr));
-   merge_alias_info (new_dataref_ptr, dataref_ptr);
  
    if (!ptr_incr)
      return new_dataref_ptr;
--- 1297,1302 ----
*************** vectorizable_store (gimple stmt, gimple_
*** 5442,5450 ****
  	  data_ref = build_fold_indirect_ref (dataref_ptr);
  	  /* If accesses through a pointer to vectype do not alias the original
  	     memory reference we have a problem.  This should never happen.  */
! 	  gcc_assert (get_alias_set (data_ref) == get_alias_set (gimple_assign_lhs (stmt))
! 		      || alias_set_subset_of (get_alias_set (data_ref), 
! 					      get_alias_set (gimple_assign_lhs (stmt))));
  
  	  /* Arguments are ready. Create the new vector stmt.  */
  	  new_stmt = gimple_build_assign (data_ref, vec_oprnd);
--- 5437,5460 ----
  	  data_ref = build_fold_indirect_ref (dataref_ptr);
  	  /* If accesses through a pointer to vectype do not alias the original
  	     memory reference we have a problem.  This should never happen.  */
! 	  if (!alias_sets_conflict_p (get_alias_set (data_ref), get_alias_set (gimple_assign_lhs (stmt))))
! 	    {
! 	      tree old = TREE_TYPE (dataref_ptr);
! 	      tree xnew;
! 	      unsigned i;
! 	      xnew = build_pointer_type_for_mode (TREE_TYPE (old),
! 						 ptr_mode, true);
! 	      xnew = build_qualified_type (xnew, TYPE_QUALS (old));
! 	      TREE_TYPE (SSA_NAME_VAR (dataref_ptr)) = xnew;
! 	      for (i = 0; i < num_ssa_names; ++i)
! 		{
! 		  tree name = ssa_name (i);
! 		  if (name
! 		      && SSA_NAME_VAR (name) == SSA_NAME_VAR (dataref_ptr))
! 		    TREE_TYPE (name) = xnew;
! 		}
! 	    }
! 	  gcc_assert (alias_sets_conflict_p (get_alias_set (data_ref), get_alias_set (gimple_assign_lhs (stmt))));
  
  	  /* Arguments are ready. Create the new vector stmt.  */
  	  new_stmt = gimple_build_assign (data_ref, vec_oprnd);
*************** vectorizable_load (gimple stmt, gimple_s
*** 6670,6678 ****
  	    }
  	  /* If accesses through a pointer to vectype do not alias the original
  	     memory reference we have a problem.  This should never happen.  */
! 	  gcc_assert (get_alias_set (data_ref) == get_alias_set (gimple_assign_rhs1 (stmt))
! 		      || alias_set_subset_of (get_alias_set (data_ref),
! 					      get_alias_set (gimple_assign_rhs1 (stmt))));
  	  vec_dest = vect_create_destination_var (scalar_dest, vectype);
  	  new_stmt = gimple_build_assign (vec_dest, data_ref);
  	  new_temp = make_ssa_name (vec_dest, new_stmt);
--- 6680,6703 ----
  	    }
  	  /* If accesses through a pointer to vectype do not alias the original
  	     memory reference we have a problem.  This should never happen.  */
! 	  if (!alias_sets_conflict_p (get_alias_set (data_ref), get_alias_set (gimple_assign_rhs1 (stmt))))
! 	    {
! 	      tree old = TREE_TYPE (dataref_ptr);
! 	      tree xnew;
! 	      unsigned i;
! 	      xnew = build_pointer_type_for_mode (TREE_TYPE (old),
! 						 ptr_mode, true);
! 	      xnew = build_qualified_type (xnew, TYPE_QUALS (old));
! 	      TREE_TYPE (SSA_NAME_VAR (dataref_ptr)) = xnew; 
! 	      for (i = 0; i < num_ssa_names; ++i)
! 		{                             
! 		  tree name = ssa_name (i);
! 		  if (name
! 		      && SSA_NAME_VAR (name) == SSA_NAME_VAR (dataref_ptr))
! 		    TREE_TYPE (name) = xnew;
! 		} 
! 	    }
! 	  gcc_assert (alias_sets_conflict_p (get_alias_set (data_ref), get_alias_set (gimple_assign_rhs1 (stmt))));
  	  vec_dest = vect_create_destination_var (scalar_dest, vectype);
  	  new_stmt = gimple_build_assign (vec_dest, data_ref);
  	  new_temp = make_ssa_name (vec_dest, new_stmt);
Index: gcc/testsuite/gcc.c-torture/compile/pr37955.c
===================================================================
*** gcc/testsuite/gcc.c-torture/compile/pr37955.c	(revision 0)
--- gcc/testsuite/gcc.c-torture/compile/pr37955.c	(revision 0)
***************
*** 0 ****
--- 1,19 ----
+ typedef struct
+ {
+   enum { NotConnected = 0 } conn_state;
+   unsigned int conn_hndl;
+ } AEP_CONNECTION_ENTRY;
+ 
+ static AEP_CONNECTION_ENTRY aep_app_conn_table[256];
+ 
+ void aep_mod_exp (void)
+ {
+   int count;
+ 
+   for (count = 0; count < 256; count++)
+     {
+       aep_app_conn_table[count].conn_state = NotConnected;
+       aep_app_conn_table[count].conn_hndl = 0;
+     }
+ }
+ 


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