diff mbox

Fix PR79683

Message ID alpine.LSU.2.20.1702230954290.8538@zhemvz.fhfr.qr
State New
Headers show

Commit Message

Richard Biener Feb. 23, 2017, 8:55 a.m. UTC
The following fixes BB vectorization to not forget addr-space 
qualifications of loads.

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

Richard.

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

	PR tree-optimization/79683
	* tree-vect-stmts.c (vect_analyze_stmt): Do not overwrite
	vector types for data-refs.

	* gcc.target/i386/pr79683.c: New testcase.
diff mbox

Patch

Index: gcc/tree-vect-stmts.c
===================================================================
--- gcc/tree-vect-stmts.c	(revision 245676)
+++ gcc/tree-vect-stmts.c	(working copy)
@@ -8486,37 +8486,42 @@  vect_analyze_stmt (gimple *stmt, bool *n
     {
       gcc_assert (PURE_SLP_STMT (stmt_info));
 
-      scalar_type = TREE_TYPE (gimple_get_lhs (stmt));
-      if (dump_enabled_p ())
-        {
-          dump_printf_loc (MSG_NOTE, vect_location,
-                           "get vectype for scalar type:  ");
-          dump_generic_expr (MSG_NOTE, TDF_SLIM, scalar_type);
-          dump_printf (MSG_NOTE, "\n");
-        }
+      /* Memory accesses already got their vector type assigned
+         in vect_analyze_data_refs.  */
+      if (! STMT_VINFO_DATA_REF (stmt_info))
+	{
+	  scalar_type = TREE_TYPE (gimple_get_lhs (stmt));
+	  if (dump_enabled_p ())
+	    {
+	      dump_printf_loc (MSG_NOTE, vect_location,
+			       "get vectype for scalar type:  ");
+	      dump_generic_expr (MSG_NOTE, TDF_SLIM, scalar_type);
+	      dump_printf (MSG_NOTE, "\n");
+	    }
 
-      vectype = get_vectype_for_scalar_type (scalar_type);
-      if (!vectype)
-        {
-          if (dump_enabled_p ())
-            {
-               dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-                                "not SLPed: unsupported data-type ");
-               dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
-                                  scalar_type);
-              dump_printf (MSG_MISSED_OPTIMIZATION, "\n");
-            }
-          return false;
-        }
+	  vectype = get_vectype_for_scalar_type (scalar_type);
+	  if (!vectype)
+	    {
+	      if (dump_enabled_p ())
+		{
+		  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+				   "not SLPed: unsupported data-type ");
+		  dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
+				     scalar_type);
+		  dump_printf (MSG_MISSED_OPTIMIZATION, "\n");
+		}
+	      return false;
+	    }
 
-      if (dump_enabled_p ())
-        {
-          dump_printf_loc (MSG_NOTE, vect_location, "vectype:  ");
-          dump_generic_expr (MSG_NOTE, TDF_SLIM, vectype);
-          dump_printf (MSG_NOTE, "\n");
-        }
+	  if (dump_enabled_p ())
+	    {
+	      dump_printf_loc (MSG_NOTE, vect_location, "vectype:  ");
+	      dump_generic_expr (MSG_NOTE, TDF_SLIM, vectype);
+	      dump_printf (MSG_NOTE, "\n");
+	    }
 
-      STMT_VINFO_VECTYPE (stmt_info) = vectype;
+	  STMT_VINFO_VECTYPE (stmt_info) = vectype;
+	}
    }
 
   if (STMT_VINFO_RELEVANT_P (stmt_info))
Index: gcc/testsuite/gcc.target/i386/pr79683.c
===================================================================
--- gcc/testsuite/gcc.target/i386/pr79683.c	(nonexistent)
+++ gcc/testsuite/gcc.target/i386/pr79683.c	(working copy)
@@ -0,0 +1,16 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O3 -msse2" } */
+
+struct s {
+    __INT64_TYPE__ a;
+    __INT64_TYPE__ b;
+};
+void test(struct s __seg_gs *x) {
+    x->a += 1;
+    x->b -= 1;
+}
+
+/* We get the function vectorized, verify the load and store are
+   address-space qualified.  */
+/* { dg-final { scan-assembler-times "padd" 1 } } */
+/* { dg-final { scan-assembler-times "%gs" 2 } } */