aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@linaro.org>2017-07-02 08:37:07 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2017-07-02 08:37:07 +0000
commitc34d09274e72031d768e18d3f2365a1532357879 (patch)
tree917bb0ecab647d97b53a265919a4c8ac41d0a5ad /gcc
parent86ae8a3d6664c957337af20d2b56c461152696bd (diff)
downloadgcc-c34d09274e72031d768e18d3f2365a1532357879.zip
gcc-c34d09274e72031d768e18d3f2365a1532357879.tar.gz
gcc-c34d09274e72031d768e18d3f2365a1532357879.tar.bz2
PR81136: ICE from inconsistent DR_MISALIGNMENTs
The test case triggered this assert in vect_update_misalignment_for_peel: gcc_assert (DR_MISALIGNMENT (dr) / dr_size == DR_MISALIGNMENT (dr_peel) / dr_peel_size); The problem was that: - one memory reference guaranteed a high base alignment, when considering that reference in isolation. This meant that we could calculate the vector misalignment for its DR at compile time. - the other memory reference only guaranteed a low base alignment, when considering that reference in isolation. We therefore couldn't calculate the vector misalignment for its DR at compile time. - when looking at the values of the two addresses as a pair (rather than the memory references), it was obvious that they had the same misalignment, whatever that misalignment happened to be. This is working as designed, so the patch restricts the assert to cases in which both addresses have a compile-time misalignment. In the test case this looks like a missed opportunity. Both references are unconditional, so it should be possible to use the highest of the available base alignment guarantees when analyzing each reference. A later patch does this, but the problem would still remain for conditional references. 2017-07-02 Richard Sandiford <richard.sandiford@linaro.org> gcc/ PR tree-optimization/81136 * tree-vect-data-refs.c (vect_update_misalignment_for_peel): Only assert that two references with the same misalignment have the same compile-time misalignment if those compile-time misalignments are known. gcc/testsuite/ PR tree-optimization/81136 * gcc.dg/vect/pr81136.c: New test. From-SVN: r249878
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr81136.c16
-rw-r--r--gcc/tree-vect-data-refs.c6
4 files changed, 33 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index bbcff74..76944d5 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2017-07-02 Richard Sandiford <richard.sandiford@linaro.org>
+
+ PR tree-optimization/81136
+ * tree-vect-data-refs.c (vect_update_misalignment_for_peel): Only
+ assert that two references with the same misalignment have the same
+ compile-time misalignment if those compile-time misalignments
+ are known.
+
2017-07-01 Andi Kleen <ak@linux.intel.com>
* print-tree.c (print_node): Print all attributes.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index c71540a..4625921 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2017-07-02 Richard Sandiford <richard.sandiford@linaro.org>
+
+ PR tree-optimization/81136
+ * gcc.dg/vect/pr81136.c: New test.
+
2017-07-01 Jakub Jelinek <jakub@redhat.com>
PR sanitizer/81262
diff --git a/gcc/testsuite/gcc.dg/vect/pr81136.c b/gcc/testsuite/gcc.dg/vect/pr81136.c
new file mode 100644
index 0000000..24bd8fa
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr81136.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+struct __attribute__((aligned (32)))
+{
+ char misaligner;
+ int foo[100];
+ int bar[100];
+} *a;
+
+void
+fn1 (int n)
+{
+ int *b = a->foo;
+ for (int i = 0; i < n; i++)
+ a->bar[i] = b[i];
+}
diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c
index 623acf6..1595bb4 100644
--- a/gcc/tree-vect-data-refs.c
+++ b/gcc/tree-vect-data-refs.c
@@ -906,8 +906,10 @@ vect_update_misalignment_for_peel (struct data_reference *dr,
{
if (current_dr != dr)
continue;
- gcc_assert (DR_MISALIGNMENT (dr) / dr_size ==
- DR_MISALIGNMENT (dr_peel) / dr_peel_size);
+ gcc_assert (!known_alignment_for_access_p (dr)
+ || !known_alignment_for_access_p (dr_peel)
+ || (DR_MISALIGNMENT (dr) / dr_size
+ == DR_MISALIGNMENT (dr_peel) / dr_peel_size));
SET_DR_MISALIGNMENT (dr, 0);
return;
}