re PR tree-optimization/79683 (SLP vectorizer drops gs: prefix)
authorRichard Biener <rguenther@suse.de>
Thu, 23 Feb 2017 11:43:51 +0000 (11:43 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 23 Feb 2017 11:43:51 +0000 (11:43 +0000)
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.

From-SVN: r245679

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr79683.c [new file with mode: 0644]
gcc/tree-vect-stmts.c

index 6c4201162b230dbbd97de266505422f4e5991e6d..820f673ec320b2fa0302fb79e0599b71c0d3c20e 100644 (file)
@@ -1,3 +1,9 @@
+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.
+
 2017-02-23  Martin Liska  <mliska@suse.cz>
 
        * params.def (PARAM_MIN_NONDEBUG_INSN_UID): Change default to 0.
index d900cc3496ba6e8ac1a3334958cddd13dd6a01f0..95cc1d5a318e48f843df114ed38a110c93265529 100644 (file)
@@ -1,3 +1,8 @@
+2017-02-23  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/79683
+       * gcc.target/i386/pr79683.c: New testcase.
+
 2017-02-22  Jeff Law  <law@redhat.com>
 
        PR tree-optimization/79578
diff --git a/gcc/testsuite/gcc.target/i386/pr79683.c b/gcc/testsuite/gcc.target/i386/pr79683.c
new file mode 100644 (file)
index 0000000..cbd43fd
--- /dev/null
@@ -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 } } */
index bf07efda935346ac3f5174eef56d09417fa1f532..59768824c0fa87e8eaa17e882f87c95e9dca4223 100644 (file)
@@ -8486,37 +8486,42 @@ vect_analyze_stmt (gimple *stmt, bool *need_to_vectorize, slp_tree node)
     {
       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))