Fix DR_GROUP_GAP for strided accesses (PR 92677)

Message ID mpt1rtrymv7.fsf@arm.com
State New
Headers show
Series
  • Fix DR_GROUP_GAP for strided accesses (PR 92677)
Related show

Commit Message

Richard Sandiford Nov. 29, 2019, 10:53 a.m.
When dissolving an SLP-only group of accesses, we should only set
the gap to group_size - 1 for normal non-strided groups.

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

Richard


2019-11-29  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
	PR tree-optimization/92677
	* tree-vect-loop.c (vect_dissolve_slp_only_groups): Set the gap
	to zero when dissolving a group of strided accesses.

gcc/testsuite/
	PR tree-optimization/92677
	* gcc.dg/vect/pr92677.c: New test.

Comments

Richard Biener Nov. 29, 2019, 12:22 p.m. | #1
On Fri, Nov 29, 2019 at 11:53 AM Richard Sandiford
<richard.sandiford@arm.com> wrote:
>

> When dissolving an SLP-only group of accesses, we should only set

> the gap to group_size - 1 for normal non-strided groups.

>

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


OK.  Probably also broken on branch(es).

Richard.

> Richard

>

>

> 2019-11-29  Richard Sandiford  <richard.sandiford@arm.com>

>

> gcc/

>         PR tree-optimization/92677

>         * tree-vect-loop.c (vect_dissolve_slp_only_groups): Set the gap

>         to zero when dissolving a group of strided accesses.

>

> gcc/testsuite/

>         PR tree-optimization/92677

>         * gcc.dg/vect/pr92677.c: New test.

>

> Index: gcc/tree-vect-loop.c

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

> --- gcc/tree-vect-loop.c        2019-11-29 09:13:43.764143091 +0000

> +++ gcc/tree-vect-loop.c        2019-11-29 10:52:30.475476141 +0000

> @@ -1829,7 +1829,10 @@ vect_dissolve_slp_only_groups (loop_vec_

>                   DR_GROUP_FIRST_ELEMENT (vinfo) = vinfo;

>                   DR_GROUP_NEXT_ELEMENT (vinfo) = NULL;

>                   DR_GROUP_SIZE (vinfo) = 1;

> -                 DR_GROUP_GAP (vinfo) = group_size - 1;

> +                 if (STMT_VINFO_STRIDED_P (first_element))

> +                   DR_GROUP_GAP (vinfo) = 0;

> +                 else

> +                   DR_GROUP_GAP (vinfo) = group_size - 1;

>                   vinfo = next;

>                 }

>             }

> Index: gcc/testsuite/gcc.dg/vect/pr92677.c

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

> --- /dev/null   2019-09-17 11:41:18.176664108 +0100

> +++ gcc/testsuite/gcc.dg/vect/pr92677.c 2019-11-29 10:52:30.475476141 +0000

> @@ -0,0 +1,26 @@

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

> +/* { dg-additional-options "-O3" } */

> +

> +int a, c;

> +int *b;

> +long d;

> +double *e;

> +

> +void fn1() {

> +  long f;

> +  double g, h;

> +  while (c) {

> +    if (d) {

> +      g = *e;

> +      *(b + 4) = g;

> +    }

> +    if (f) {

> +      h = *(e + 2);

> +      *(b + 6) = h;

> +    }

> +    e += a;

> +    b += 8;

> +    c--;

> +    d += 2;

> +  }

> +}
Richard Sandiford Nov. 29, 2019, 2:56 p.m. | #2
Richard Biener <richard.guenther@gmail.com> writes:
> On Fri, Nov 29, 2019 at 11:53 AM Richard Sandiford

> <richard.sandiford@arm.com> wrote:

>>

>> When dissolving an SLP-only group of accesses, we should only set

>> the gap to group_size - 1 for normal non-strided groups.

>>

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

>

> OK.  Probably also broken on branch(es).


It looks like it's trunk only -- we didn't dissolve DR groups here
until the support for SLP masked loads (r271704).

Thanks,
Richard

>

> Richard.

>

>> Richard

>>

>>

>> 2019-11-29  Richard Sandiford  <richard.sandiford@arm.com>

>>

>> gcc/

>>         PR tree-optimization/92677

>>         * tree-vect-loop.c (vect_dissolve_slp_only_groups): Set the gap

>>         to zero when dissolving a group of strided accesses.

>>

>> gcc/testsuite/

>>         PR tree-optimization/92677

>>         * gcc.dg/vect/pr92677.c: New test.

>>

>> Index: gcc/tree-vect-loop.c

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

>> --- gcc/tree-vect-loop.c        2019-11-29 09:13:43.764143091 +0000

>> +++ gcc/tree-vect-loop.c        2019-11-29 10:52:30.475476141 +0000

>> @@ -1829,7 +1829,10 @@ vect_dissolve_slp_only_groups (loop_vec_

>>                   DR_GROUP_FIRST_ELEMENT (vinfo) = vinfo;

>>                   DR_GROUP_NEXT_ELEMENT (vinfo) = NULL;

>>                   DR_GROUP_SIZE (vinfo) = 1;

>> -                 DR_GROUP_GAP (vinfo) = group_size - 1;

>> +                 if (STMT_VINFO_STRIDED_P (first_element))

>> +                   DR_GROUP_GAP (vinfo) = 0;

>> +                 else

>> +                   DR_GROUP_GAP (vinfo) = group_size - 1;

>>                   vinfo = next;

>>                 }

>>             }

>> Index: gcc/testsuite/gcc.dg/vect/pr92677.c

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

>> --- /dev/null   2019-09-17 11:41:18.176664108 +0100

>> +++ gcc/testsuite/gcc.dg/vect/pr92677.c 2019-11-29 10:52:30.475476141 +0000

>> @@ -0,0 +1,26 @@

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

>> +/* { dg-additional-options "-O3" } */

>> +

>> +int a, c;

>> +int *b;

>> +long d;

>> +double *e;

>> +

>> +void fn1() {

>> +  long f;

>> +  double g, h;

>> +  while (c) {

>> +    if (d) {

>> +      g = *e;

>> +      *(b + 4) = g;

>> +    }

>> +    if (f) {

>> +      h = *(e + 2);

>> +      *(b + 6) = h;

>> +    }

>> +    e += a;

>> +    b += 8;

>> +    c--;

>> +    d += 2;

>> +  }

>> +}

Patch

Index: gcc/tree-vect-loop.c
===================================================================
--- gcc/tree-vect-loop.c	2019-11-29 09:13:43.764143091 +0000
+++ gcc/tree-vect-loop.c	2019-11-29 10:52:30.475476141 +0000
@@ -1829,7 +1829,10 @@  vect_dissolve_slp_only_groups (loop_vec_
 		  DR_GROUP_FIRST_ELEMENT (vinfo) = vinfo;
 		  DR_GROUP_NEXT_ELEMENT (vinfo) = NULL;
 		  DR_GROUP_SIZE (vinfo) = 1;
-		  DR_GROUP_GAP (vinfo) = group_size - 1;
+		  if (STMT_VINFO_STRIDED_P (first_element))
+		    DR_GROUP_GAP (vinfo) = 0;
+		  else
+		    DR_GROUP_GAP (vinfo) = group_size - 1;
 		  vinfo = next;
 		}
 	    }
Index: gcc/testsuite/gcc.dg/vect/pr92677.c
===================================================================
--- /dev/null	2019-09-17 11:41:18.176664108 +0100
+++ gcc/testsuite/gcc.dg/vect/pr92677.c	2019-11-29 10:52:30.475476141 +0000
@@ -0,0 +1,26 @@ 
+/* { dg-do compile } */
+/* { dg-additional-options "-O3" } */
+
+int a, c;
+int *b;
+long d;
+double *e;
+
+void fn1() {
+  long f;
+  double g, h;
+  while (c) {
+    if (d) {
+      g = *e;
+      *(b + 4) = g;
+    }
+    if (f) {
+      h = *(e + 2);
+      *(b + 6) = h;
+    }
+    e += a;
+    b += 8;
+    c--;
+    d += 2;
+  }
+}