This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR36034, wrong-code with SLP vectorization
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Cc: irar at il dot ibm dot com
- Date: Thu, 24 Apr 2008 16:19:53 +0200 (CEST)
- Subject: [PATCH] Fix PR36034, wrong-code with SLP vectorization
This patch from Ira fixes PR36034, a latent SLP vectorization bug exposed
by the early loop unrolling pass.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.
I will apply this to the 4.3 branch as well after testing there.
Thanks,
Richard.
2008-04-24 Ira Rosen <irar@il.ibm.com>
Richard Guenther <rguenther@suse.de>
PR tree-optimization/36034
* tree-vect-analyze.c (vect_analyze_group_access): SLP is
incapable of dealing with loads with gaps.
* gcc.c-torture/execute/pr36034-1.c: New testcase.
* gcc.c-torture/execute/pr36034-2.c: Likewise.
Index: tree-vect-analyze.c
===================================================================
*** tree-vect-analyze.c (revision 134623)
--- tree-vect-analyze.c (working copy)
*************** vect_analyze_group_access (struct data_r
*** 2226,2236 ****
/* Check that the size of the interleaving is equal to STEP for stores,
i.e., that there are no gaps. */
! if (!DR_IS_READ (dr) && dr_step != count_in_bytes)
{
! if (vect_print_dump_info (REPORT_DETAILS))
! fprintf (vect_dump, "interleaved store with gaps");
! return false;
}
/* Check that STEP is a multiple of type size. */
--- 2226,2241 ----
/* Check that the size of the interleaving is equal to STEP for stores,
i.e., that there are no gaps. */
! if (dr_step != count_in_bytes)
{
! if (DR_IS_READ (dr))
! slp_impossible = true;
! else
! {
! if (vect_print_dump_info (REPORT_DETAILS))
! fprintf (vect_dump, "interleaved store with gaps");
! return false;
! }
}
/* Check that STEP is a multiple of type size. */
Index: testsuite/gcc.c-torture/execute/pr36034-1.c
===================================================================
*** testsuite/gcc.c-torture/execute/pr36034-1.c (revision 0)
--- testsuite/gcc.c-torture/execute/pr36034-1.c (revision 0)
***************
*** 0 ****
--- 1,32 ----
+ double x[5][10] = { { 10, 11, 12, 13, 14, 15, -1, -1, -1, -1 },
+ { 21, 22, 23, 24, 25, 26, -1, -1, -1, -1 },
+ { 32, 33, 34, 35, 36, 37, -1, -1, -1, -1 },
+ { 43, 44, 45, 46, 47, 48, -1, -1, -1, -1 },
+ { 54, 55, 56, 57, 58, 59, -1, -1, -1, -1 } };
+ double tmp[5][6];
+
+ void __attribute__((noinline))
+ test (void)
+ {
+ int i, j;
+ for (i = 0; i < 5; ++i)
+ {
+ tmp[i][0] = x[i][0];
+ tmp[i][1] = x[i][1];
+ tmp[i][2] = x[i][2];
+ tmp[i][3] = x[i][3];
+ tmp[i][4] = x[i][4];
+ tmp[i][5] = x[i][5];
+ }
+ }
+ extern void abort (void);
+ int main()
+ {
+ int i, j;
+ test();
+ for (i = 0; i < 5; ++i)
+ for (j = 0; j < 6; ++j)
+ if (tmp[i][j] == -1)
+ abort ();
+ return 0;
+ }
Index: testsuite/gcc.c-torture/execute/pr36034-2.c
===================================================================
*** testsuite/gcc.c-torture/execute/pr36034-2.c (revision 0)
--- testsuite/gcc.c-torture/execute/pr36034-2.c (revision 0)
***************
*** 0 ****
--- 1,32 ----
+ double x[50] = { 10, 11, 12, 13, 14, 15, -1, -1, -1, -1,
+ 21, 22, 23, 24, 25, 26, -1, -1, -1, -1,
+ 32, 33, 34, 35, 36, 37, -1, -1, -1, -1,
+ 43, 44, 45, 46, 47, 48, -1, -1, -1, -1,
+ 54, 55, 56, 57, 58, 59, -1, -1, -1, -1 };
+ double tmp[30];
+
+ void __attribute__((noinline))
+ test (void)
+ {
+ int i, j;
+ for (i = 0; i < 5; ++i)
+ {
+ tmp[i*6] = x[i*10];
+ tmp[i*6+1] = x[i*10+1];
+ tmp[i*6+2] = x[i*10+2];
+ tmp[i*6+3] = x[i*10+3];
+ tmp[i*6+4] = x[i*10+4];
+ tmp[i*6+5] = x[i*10+5];
+ }
+ }
+ extern void abort (void);
+ int main()
+ {
+ int i, j;
+ test();
+ for (i = 0; i < 5; ++i)
+ for (j = 0; j < 6; ++j)
+ if (tmp[i*6+j] == -1)
+ abort ();
+ return 0;
+ }