File gcc-power7-sles-11sp1.patch02c of Package gcc43

2009-10-15  Michael Meissner  <meissner@linux.vnet.ibm.com>
	    Pat Haugen  <pthaugen@us.ibm.com>
	    Revital Eres <ERES@il.ibm.com>
	    Peter Bergner  <bergner@vnet.ibm.com>
	
	Backport rs6000 changes from GCC 4.5 mainline to 4.3 that includes
	improved support for vector misalignment.

	2009-09-17  Revital Eres  <eres@il.ibm.com>

	* doc/tm.texi (TARGET_SUPPORT_VECTOR_MISALIGNMENT): Document.
	* targhooks.c (default_builtin_support_vector_misalignment):
	New builtin function.
	* targhooks.h (default_builtin_support_vector_misalignment):
	Declare.
	* target.h (builtin_support_vector_misalignment):
	New field in struct gcc_target.
	* tree-vectorizer.c (vect_supportable_dr_alignment): Call
	new builtin function.
	* target-def.h (TARGET_SUPPORT_VECTOR_MISALIGNMENT):
	Define.

diff -rupN --exclude='*~' --exclude=autom4te.cache sles-11sp1-orig/gcc/target-def.h sles-11sp1/gcc/target-def.h
--- sles-11sp1-orig/gcc/target-def.h	2008-06-30 07:54:13.000000000 -0400
+++ sles-11sp1/gcc/target-def.h	2009-10-13 13:01:47.000000000 -0400
@@ -364,6 +364,8 @@
 #define TARGET_VECTORIZE_BUILTIN_VECTORIZATION_COST 0
 #define TARGET_VECTOR_ALIGNMENT_REACHABLE \
   default_builtin_vector_alignment_reachable
+#define TARGET_SUPPORT_VECTOR_MISALIGNMENT \
+  default_builtin_support_vector_misalignment
 
 #define TARGET_VECTORIZE                                                \
   {									\
@@ -373,7 +375,8 @@
     TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_EVEN,                            \
     TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_ODD,				\
     TARGET_VECTORIZE_BUILTIN_VECTORIZATION_COST,			\
-    TARGET_VECTOR_ALIGNMENT_REACHABLE					\
+    TARGET_VECTOR_ALIGNMENT_REACHABLE,					\
+    TARGET_SUPPORT_VECTOR_MISALIGNMENT					\
   }
 
 #define TARGET_DEFAULT_TARGET_FLAGS 0
diff -rupN --exclude='*~' --exclude=autom4te.cache sles-11sp1-orig/gcc/target.h sles-11sp1/gcc/target.h
--- sles-11sp1-orig/gcc/target.h	2008-06-30 07:54:12.000000000 -0400
+++ sles-11sp1/gcc/target.h	2009-10-13 13:00:59.000000000 -0400
@@ -438,6 +438,11 @@ struct gcc_target
     /* Return true if vector alignment is reachable (by peeling N
        iterations) for the given type.  */
     bool (* vector_alignment_reachable) (const_tree, bool);
+    /* Return true if the target supports misaligned store/load of a
+       specific factor denoted in the third parameter.  The last parameter
+       is true if the access is defined in a packed struct.  */
+    bool (* builtin_support_vector_misalignment) (enum machine_mode,
+                                                  const_tree, int, bool);
   } vectorize;
 
   /* The initial value of target_flags.  */
diff -rupN --exclude='*~' --exclude=autom4te.cache sles-11sp1-orig/gcc/targhooks.c sles-11sp1/gcc/targhooks.c
--- sles-11sp1-orig/gcc/targhooks.c	2008-06-30 07:54:12.000000000 -0400
+++ sles-11sp1/gcc/targhooks.c	2009-10-13 13:00:36.000000000 -0400
@@ -691,6 +691,23 @@ tree default_mangle_decl_assembler_name 
    return id;
 }
 
+/* By default, assume that a target supports any factor of misalignment
+   memory access if it supports movmisalign patten. 
+   is_packed is true if the memory access is defined in a packed struct.  */
+bool
+default_builtin_support_vector_misalignment (enum machine_mode mode,
+					     const_tree type
+					     ATTRIBUTE_UNUSED,
+					     int misalignment
+					     ATTRIBUTE_UNUSED,
+					     bool is_packed
+					     ATTRIBUTE_UNUSED)
+{
+  if (optab_handler (movmisalign_optab, mode)->insn_code != CODE_FOR_nothing)
+    return true;
+  return false;
+}
+
 bool
 default_builtin_vector_alignment_reachable (const_tree type, bool is_packed)
 {
diff -rupN --exclude='*~' --exclude=autom4te.cache sles-11sp1-orig/gcc/targhooks.h sles-11sp1/gcc/targhooks.h
--- sles-11sp1-orig/gcc/targhooks.h	2008-06-30 07:54:12.000000000 -0400
+++ sles-11sp1/gcc/targhooks.h	2009-10-13 13:00:47.000000000 -0400
@@ -70,6 +70,10 @@ extern tree default_builtin_vectorized_c
 extern tree default_builtin_reciprocal (enum built_in_function, bool, bool);
 
 extern bool default_builtin_vector_alignment_reachable (const_tree, bool);
+extern bool
+default_builtin_support_vector_misalignment (enum machine_mode mode,
+					     const_tree,
+					     int, bool); 
 
 /* These are here, and not in hooks.[ch], because not all users of
    hooks.h include tm.h, and thus we don't have CUMULATIVE_ARGS.  */
diff -rupN --exclude='*~' --exclude=autom4te.cache sles-11sp1-orig/gcc/tree-vectorizer.c sles-11sp1/gcc/tree-vectorizer.c
--- sles-11sp1-orig/gcc/tree-vectorizer.c	2009-10-09 17:11:06.000000000 -0400
+++ sles-11sp1/gcc/tree-vectorizer.c	2009-10-13 13:01:17.000000000 -0400
@@ -1938,6 +1938,9 @@ vect_supportable_dr_alignment (struct da
 
   if (DR_IS_READ (dr))
     {
+      bool is_packed = false;
+      tree type = (TREE_TYPE (DR_REF (dr)));
+
       if (optab_handler (vec_realign_load_optab, mode)->insn_code != 
 						   	     CODE_FOR_nothing
 	  && (!targetm.vectorize.builtin_mask_for_load
@@ -1949,9 +1952,17 @@ vect_supportable_dr_alignment (struct da
 	    else
 	      return dr_explicit_realign_optimized;
 	}
+      if (!known_alignment_for_access_p (dr))
+        {
+          tree ba = DR_BASE_OBJECT (dr);
+
+          if (ba)
+            is_packed = contains_packed_reference (ba);
+        }
 
-      if (optab_handler (movmisalign_optab, mode)->insn_code != 
-							     CODE_FOR_nothing)
+      if (targetm.vectorize.
+          builtin_support_vector_misalignment (mode, type,
+                                               DR_MISALIGNMENT (dr), is_packed))
 	/* Can't software pipeline the loads, but can at least do them.  */
 	return dr_unaligned_supported;
     }
diff -rupN --exclude='*~' --exclude=autom4te.cache sles-11sp1-orig/gcc/doc/tm.texi sles-11sp1/gcc/doc/tm.texi
--- sles-11sp1-orig/gcc/doc/tm.texi	2009-10-09 17:15:53.000000000 -0400
+++ sles-11sp1/gcc/doc/tm.texi	2009-10-13 13:00:13.000000000 -0400
@@ -5541,6 +5541,14 @@ the vectorized function shall be of vect
 argument types should be @var{vec_type_in}.
 @end deftypefn
 
+@deftypefn {Target Hook} bool TARGET_SUPPORT_VECTOR_MISALIGNMENT (enum machine_mode @var{mode}, tree @var{type}, int @var{misalignment}, bool @var{is_packed})
+This hook should return true if the target supports misaligned vector
+store/load of a specific factor denoted in the @var{misalignment}
+parameter.  The vector store/load should be of machine mode @var{mode} and
+the elements in the vectors should be of type @var{type}.  @var{is_packed}
+parameter is true if the memory access is defined in a packed struct.
+@end deftypefn
+
 @node Anchored Addresses
 @section Anchored Addresses
 @cindex anchored addresses
openSUSE Build Service is sponsored by