Revert DECL_USER_ALIGN part of r241959
commit0471f1c519b7fc7271475e080023553a65a0a6d3
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 5 Jan 2018 13:49:46 +0000 (5 13:49 +0000)
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 5 Jan 2018 13:49:46 +0000 (5 13:49 +0000)
treecde6570c50283787d3500e8a6cafc99a6cb66f1d
parent1c84972bf173d504c0232890160c8b1682faefef
Revert DECL_USER_ALIGN part of r241959

r241959 included code to stop the vectoriser increasing the alignment of
a "user-aligned" variable.  This wasn't the main purpose of the patch,
but was done for consistency with pass_increase_alignment, and was
needed to make the testcase work.

The documentation for the aligned attribute says:

  This attribute specifies a minimum alignment for the variable or
  structure field, measured in bytes.

so I think it's reasonable for the vectoriser to increase the
alignment further, if that helps us to vectorise code.  It's also
useful if the "user" alignment actually came from an earlier pass
rather than the source code.

A possible counterexample came up when this was discussed on the lists.
Users who are trying to collate things from several translation units
into a single section can use:

  __attribute__((section ("whatever"), aligned(N)))

and would not want extra padding.  It turns out that the supported way
of doing that is to add a "used" attribute, which works even when no
"aligned" attribute is given.

2018-01-05  Richard Sandiford  <richard.sandiford@linaro.org>

gcc/
* tree-vect-data-refs.c (vect_compute_data_ref_alignment): Don't
punt for user-aligned variables.

gcc/testsuite/
* gcc.dg/vect/vect-align-4.c: New test.
* gcc.dg/vect/vect-nb-iter-ub-2.c (cc): Remove alignment attribute
and redefine as a structure with an unaligned member "b".
(foo): Update accordingly.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@256277 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vect/vect-align-4.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/vect/vect-nb-iter-ub-2.c
gcc/tree-vect-data-refs.c