[PATCH] Fix PR79723

Richard Biener rguenther@suse.de
Mon Feb 27 16:09:00 GMT 2017


I am testing the following patch for another vectorizer issue with
address-space preserving.

Bootstrap / regtest running on x86_64-unknown-linux-gnu.

Richard.

2017-02-27  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/79723
	* tree-vect-stmts.c (get_vectype_for_scalar_type_and_size): Preserve
	address-space properly.

	* gcc.target/i386/pr79723.c: New testcase.

Index: gcc/tree-vect-stmts.c
===================================================================
--- gcc/tree-vect-stmts.c	(revision 245753)
+++ gcc/tree-vect-stmts.c	(working copy)
@@ -8957,6 +8957,7 @@ free_stmt_vec_info (gimple *stmt)
 static tree
 get_vectype_for_scalar_type_and_size (tree scalar_type, unsigned size)
 {
+  tree orig_scalar_type = scalar_type;
   machine_mode inner_mode = TYPE_MODE (scalar_type);
   machine_mode simd_mode;
   unsigned int nbytes = GET_MODE_SIZE (inner_mode);
@@ -9017,6 +9018,12 @@ get_vectype_for_scalar_type_and_size (tr
       && !INTEGRAL_MODE_P (TYPE_MODE (vectype)))
     return NULL_TREE;
 
+  /* Re-attach the address-space qualifier if we canonicalized the scalar
+     type.  */
+  if (TYPE_ADDR_SPACE (orig_scalar_type) != TYPE_ADDR_SPACE (vectype))
+    return build_qualified_type
+	     (vectype, KEEP_QUAL_ADDR_SPACE (TYPE_QUALS (orig_scalar_type)));
+
   return vectype;
 }
 
Index: gcc/testsuite/gcc.target/i386/pr79723.c
===================================================================
--- gcc/testsuite/gcc.target/i386/pr79723.c	(nonexistent)
+++ gcc/testsuite/gcc.target/i386/pr79723.c	(working copy)
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -msse2 -mno-avx" } */
+
+void memset_pattern_seg_gs(unsigned char * __seg_gs *s, long n)
+{
+  for (long i = 0; i < n; ++i)
+    s[i] = 0;
+}
+
+/* { dg-final { scan-assembler "mov\[au\]p.\[ \t\]\[^,\]+, %gs:" } } */



More information about the Gcc-patches mailing list