Don't group gather loads (PR83847)

Message ID 87inc3w3z9.fsf@linaro.org
State New
Headers show
Series
  • Don't group gather loads (PR83847)
Related show

Commit Message

Richard Sandiford Jan. 15, 2018, 3:12 p.m.
In the testcase we were trying to group two gather loads, even though
that isn't supported.  Fixed by explicitly disallowing grouping of
gathers and scatters.

This problem didn't show up on SVE because there we convert to
IFN_GATHER_LOAD/IFN_SCATTER_STORE pattern statements, which fail
the can_group_stmts_p check.

Tested on x86_64-linux-gnu.  OK to install?

Richard


2018-01-15  Richard Sandiford  <richard.sandiford@linaro.org>

gcc/
	* tree-vect-data-refs.c (vect_analyze_data_ref_accesses):

gcc/testsuite/
	* gcc.dg/torture/pr83847.c: New test.

Comments

Richard Biener Jan. 16, 2018, 8:14 a.m. | #1
On Mon, Jan 15, 2018 at 4:12 PM, Richard Sandiford
<richard.sandiford@linaro.org> wrote:
> In the testcase we were trying to group two gather loads, even though

> that isn't supported.  Fixed by explicitly disallowing grouping of

> gathers and scatters.

>

> This problem didn't show up on SVE because there we convert to

> IFN_GATHER_LOAD/IFN_SCATTER_STORE pattern statements, which fail

> the can_group_stmts_p check.

>

> Tested on x86_64-linux-gnu.  OK to install?


Ok.

Richard.

> Richard

>

>

> 2018-01-15  Richard Sandiford  <richard.sandiford@linaro.org>

>

> gcc/

>         * tree-vect-data-refs.c (vect_analyze_data_ref_accesses):

>

> gcc/testsuite/

>         * gcc.dg/torture/pr83847.c: New test.

>

> Index: gcc/tree-vect-data-refs.c

> ===================================================================

> --- gcc/tree-vect-data-refs.c   2018-01-13 18:02:00.948360274 +0000

> +++ gcc/tree-vect-data-refs.c   2018-01-15 12:22:47.066621712 +0000

> @@ -2923,7 +2923,8 @@ vect_analyze_data_ref_accesses (vec_info

>        data_reference_p dra = datarefs_copy[i];

>        stmt_vec_info stmtinfo_a = vinfo_for_stmt (DR_STMT (dra));

>        stmt_vec_info lastinfo = NULL;

> -      if (! STMT_VINFO_VECTORIZABLE (stmtinfo_a))

> +      if (!STMT_VINFO_VECTORIZABLE (stmtinfo_a)

> +         || STMT_VINFO_GATHER_SCATTER_P (stmtinfo_a))

>         {

>           ++i;

>           continue;

> @@ -2932,7 +2933,8 @@ vect_analyze_data_ref_accesses (vec_info

>         {

>           data_reference_p drb = datarefs_copy[i];

>           stmt_vec_info stmtinfo_b = vinfo_for_stmt (DR_STMT (drb));

> -         if (! STMT_VINFO_VECTORIZABLE (stmtinfo_b))

> +         if (!STMT_VINFO_VECTORIZABLE (stmtinfo_b)

> +             || STMT_VINFO_GATHER_SCATTER_P (stmtinfo_b))

>             break;

>

>           /* ???  Imperfect sorting (non-compatible types, non-modulo

> Index: gcc/testsuite/gcc.dg/torture/pr83847.c

> ===================================================================

> --- /dev/null   2018-01-12 06:40:27.684409621 +0000

> +++ gcc/testsuite/gcc.dg/torture/pr83847.c      2018-01-15 12:22:47.064621805 +0000

> @@ -0,0 +1,32 @@

> +/* { dg-do compile } */

> +/* { dg-additional-options "-march=bdver4" { target i?86-*-* x86_64-*-* } } */

> +

> +typedef struct {

> +  struct {

> +    int a;

> +    int b;

> +  } c;

> +} * d;

> +typedef struct {

> +  unsigned e;

> +  d f[];

> +} g;

> +g h;

> +d *k;

> +int i(int j) {

> +  if (j) {

> +    *k = *h.f;

> +    return 1;

> +  }

> +  return 0;

> +}

> +int l;

> +int m;

> +int n;

> +d o;

> +void p() {

> +  for (; i(l); l++) {

> +    n += o->c.a;

> +    m += o->c.b;

> +  }

> +}

Patch

Index: gcc/tree-vect-data-refs.c
===================================================================
--- gcc/tree-vect-data-refs.c	2018-01-13 18:02:00.948360274 +0000
+++ gcc/tree-vect-data-refs.c	2018-01-15 12:22:47.066621712 +0000
@@ -2923,7 +2923,8 @@  vect_analyze_data_ref_accesses (vec_info
       data_reference_p dra = datarefs_copy[i];
       stmt_vec_info stmtinfo_a = vinfo_for_stmt (DR_STMT (dra));
       stmt_vec_info lastinfo = NULL;
-      if (! STMT_VINFO_VECTORIZABLE (stmtinfo_a))
+      if (!STMT_VINFO_VECTORIZABLE (stmtinfo_a)
+	  || STMT_VINFO_GATHER_SCATTER_P (stmtinfo_a))
 	{
 	  ++i;
 	  continue;
@@ -2932,7 +2933,8 @@  vect_analyze_data_ref_accesses (vec_info
 	{
 	  data_reference_p drb = datarefs_copy[i];
 	  stmt_vec_info stmtinfo_b = vinfo_for_stmt (DR_STMT (drb));
-	  if (! STMT_VINFO_VECTORIZABLE (stmtinfo_b))
+	  if (!STMT_VINFO_VECTORIZABLE (stmtinfo_b)
+	      || STMT_VINFO_GATHER_SCATTER_P (stmtinfo_b))
 	    break;
 
 	  /* ???  Imperfect sorting (non-compatible types, non-modulo
Index: gcc/testsuite/gcc.dg/torture/pr83847.c
===================================================================
--- /dev/null	2018-01-12 06:40:27.684409621 +0000
+++ gcc/testsuite/gcc.dg/torture/pr83847.c	2018-01-15 12:22:47.064621805 +0000
@@ -0,0 +1,32 @@ 
+/* { dg-do compile } */
+/* { dg-additional-options "-march=bdver4" { target i?86-*-* x86_64-*-* } } */
+
+typedef struct {
+  struct {
+    int a;
+    int b;
+  } c;
+} * d;
+typedef struct {
+  unsigned e;
+  d f[];
+} g;
+g h;
+d *k;
+int i(int j) {
+  if (j) {
+    *k = *h.f;
+    return 1;
+  }
+  return 0;
+}
+int l;
+int m;
+int n;
+d o;
+void p() {
+  for (; i(l); l++) {
+    n += o->c.a;
+    m += o->c.b;
+  }
+}