vect: Fix bogus alignment assumption in alias checks [PR94994]
authorRichard Sandiford <richard.sandiford@arm.com>
Thu, 31 Dec 2020 16:51:33 +0000 (16:51 +0000)
committerRichard Sandiford <richard.sandiford@arm.com>
Thu, 31 Dec 2020 16:51:33 +0000 (16:51 +0000)
commit9fa5b473b5b8e289b6542adfd5cfaddfb3036048
tree9de2507dc2fad33cd02214bcdd24b6deac975760
parent0411210fddbd3ec27c8dc1183f40f662712a2232
vect: Fix bogus alignment assumption in alias checks [PR94994]

This PR is about a case in which the vectoriser was feeding
incorrect alignment information to tree-data-ref.c, leading
to incorrect runtime alias checks.  The alignment was taken
from the TREE_TYPE of the DR_REF, which in this case was a
COMPONENT_REF with a normally-aligned type.  However, the
underlying MEM_REF was only byte-aligned.

This patch uses dr_alignment to calculate the (byte) alignment
instead, just like we do when creating vector MEM_REFs.

gcc/
PR tree-optimization/94994
* tree-vect-data-refs.c (vect_vfa_align): Use dr_alignment.

gcc/testsuite/
PR tree-optimization/94994
* gcc.dg/vect/pr94994.c: New test.
gcc/testsuite/gcc.dg/vect/pr94994.c [new file with mode: 0644]
gcc/tree-vect-data-refs.c