From 7ef95f9cf0accd2273a09848156344639fae97f7 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Wed, 14 Jan 2015 14:06:07 +0000 Subject: [PATCH] re PR tree-optimization/59354 (Element swizzling produces invalid result with -O3) 2015-01-14 Richard Biener PR tree-optimization/59354 * tree-vect-slp.c (vect_build_slp_tree_1): Treat loads from groups larger than the slp group size as having gaps. * gcc.dg/vect/pr59354.c: New testcase. From-SVN: r219603 --- gcc/ChangeLog | 6 +++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/vect/pr59354.c | 35 +++++++++++++++++++++++++++++ gcc/tree-vect-slp.c | 7 ++++-- 4 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/vect/pr59354.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a8dc1d36f74..f5770936808 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2015-01-14 Richard Biener + + PR tree-optimization/59354 + * tree-vect-slp.c (vect_build_slp_tree_1): Treat loads from + groups larger than the slp group size as having gaps. + 2015-01-14 Andrew MacLeod PR middle-end/59448 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c630627d43c..1d228a9187c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-01-14 Richard Biener + + PR tree-optimization/59354 + * gcc.dg/vect/pr59354.c: New testcase. + 2015-01-14 Andrew Stubbs * lib/target-supports.exp diff --git a/gcc/testsuite/gcc.dg/vect/pr59354.c b/gcc/testsuite/gcc.dg/vect/pr59354.c new file mode 100644 index 00000000000..37fca9d25a4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr59354.c @@ -0,0 +1,35 @@ +/* { dg-do run } */ +/* { dg-additional-options "-O3" } */ + +#include "tree-vect.h" + +void abort (void); + +unsigned int a[256]; +unsigned char b[256]; + +int main() +{ + int i, z, x, y; + + check_vect (); + + for(i = 0; i < 256; i++) + { + a[i] = i % 5; + __asm__ volatile (""); + } + + for (z = 0; z < 16; z++) + for (y = 0; y < 4; y++) + for (x = 0; x < 4; x++) + b[y*64 + z*4 + x] = a[z*16 + y*4 + x]; + + if (b[4] != 1) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loop" "vect" { target { vect_pack_trunc } } } } */ +/* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index 2bdf1790ca0..1228a071406 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -729,8 +729,11 @@ vect_build_slp_tree_1 (loop_vec_info loop_vinfo, bb_vec_info bb_vinfo, ??? We should enhance this to only disallow gaps inside vectors. */ if ((unrolling_factor > 1 - && GROUP_FIRST_ELEMENT (vinfo_for_stmt (stmt)) == stmt - && GROUP_GAP (vinfo_for_stmt (stmt)) != 0) + && ((GROUP_FIRST_ELEMENT (vinfo_for_stmt (stmt)) == stmt + && GROUP_GAP (vinfo_for_stmt (stmt)) != 0) + /* If the group is split up then GROUP_GAP + isn't correct here, nor is GROUP_FIRST_ELEMENT. */ + || GROUP_SIZE (vinfo_for_stmt (stmt)) > group_size)) || (GROUP_FIRST_ELEMENT (vinfo_for_stmt (stmt)) != stmt && GROUP_GAP (vinfo_for_stmt (stmt)) != 1)) { -- 2.30.2