diff options
author | Richard Biener <rguenther@suse.de> | 2021-09-21 09:39:12 +0200 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2021-09-21 10:39:33 +0200 |
commit | 55b989de7679a486ad674fb154408de26ac96467 (patch) | |
tree | 11571254f03b1d6de6da84ae99d8eafc4526d255 | |
parent | 6e6bf4cd21af39a7923bae007517ab43a4c3b36a (diff) | |
download | gcc-55b989de7679a486ad674fb154408de26ac96467.zip gcc-55b989de7679a486ad674fb154408de26ac96467.tar.gz gcc-55b989de7679a486ad674fb154408de26ac96467.tar.bz2 |
tree-optimization/102421 - copy alignment info when splitting groups
This makes sure to copy and adjust alignment info when we are splitting
DR groups after alignment analysis.
2021-09-21 Richard Biener <rguenther@suse.de>
PR tree-optimization/102421
* tree-vect-loop.c (vect_dissolve_slp_only_groups): Copy and
adjust alignment info.
* g++.dg/vect/pr102421.cc: New testcase.
-rw-r--r-- | gcc/testsuite/g++.dg/vect/pr102421.cc | 34 | ||||
-rw-r--r-- | gcc/tree-vect-loop.c | 19 |
2 files changed, 53 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/vect/pr102421.cc b/gcc/testsuite/g++.dg/vect/pr102421.cc new file mode 100644 index 0000000..ccab695 --- /dev/null +++ b/gcc/testsuite/g++.dg/vect/pr102421.cc @@ -0,0 +1,34 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O3" } */ +/* { dg-additional-options "-march=armv8.2-a+sve" { target aarch64-*-* } } */ + +#include <vector> + +template<typename ValueType> +struct BasicVector +{ + ValueType& operator[](int i) { return x_[i]; } + ValueType operator[](int i) const { return x_[i]; } + ValueType x_[3]; +}; +typedef int ivec1[3]; +typedef BasicVector<double> RVec1; +void foo ( + std::vector<RVec1> &x_, + std::vector<RVec1> &xp_, + int homenr, + unsigned short* cFREEZE, + const ivec1* nFreeze) +{ + std::vector<RVec1> xp = xp_; + std::vector<RVec1> x = x_; + for (int i = 0; i < homenr; i++) + { + const int g = cFREEZE[i]; + for (int d = 0; d < 3; d++) + { + if (nFreeze[g][d] == 0) + x[i][d] = xp[i][d]; + } + } +} diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index 5a5b8da..e94356d 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -2047,6 +2047,7 @@ vect_dissolve_slp_only_groups (loop_vec_info loop_vinfo) if (STMT_VINFO_GROUPED_ACCESS (stmt_info)) { stmt_vec_info first_element = DR_GROUP_FIRST_ELEMENT (stmt_info); + dr_vec_info *dr_info = STMT_VINFO_DR_INFO (first_element); unsigned int group_size = DR_GROUP_SIZE (first_element); /* Check if SLP-only groups. */ @@ -2067,6 +2068,24 @@ vect_dissolve_slp_only_groups (loop_vec_info loop_vinfo) DR_GROUP_GAP (vinfo) = 0; else DR_GROUP_GAP (vinfo) = group_size - 1; + /* Duplicate and adjust alignment info, it needs to + be present on each group leader, see dr_misalignment. */ + if (vinfo != first_element) + { + dr_vec_info *dr_info2 = STMT_VINFO_DR_INFO (vinfo); + dr_info2->target_alignment = dr_info->target_alignment; + int misalignment = dr_info->misalignment; + if (misalignment != DR_MISALIGNMENT_UNKNOWN) + { + HOST_WIDE_INT diff + = (TREE_INT_CST_LOW (DR_INIT (dr_info2->dr)) + - TREE_INT_CST_LOW (DR_INIT (dr_info->dr))); + unsigned HOST_WIDE_INT align_c + = dr_info->target_alignment.to_constant (); + misalignment = (misalignment + diff) % align_c; + } + dr_info2->misalignment = misalignment; + } vinfo = next; } } |