summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>2018-01-05 13:49:46 +0000
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>2018-01-05 13:49:46 +0000
commit0471f1c519b7fc7271475e080023553a65a0a6d3 (patch)
treecde6570c50283787d3500e8a6cafc99a6cb66f1d
parent1c84972bf173d504c0232890160c8b1682faefef (diff)
downloadgcc-0471f1c519b7fc7271475e080023553a65a0a6d3.tar.gz
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
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/testsuite/ChangeLog7
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-align-4.c15
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-nb-iter-ub-2.c7
-rw-r--r--gcc/tree-vect-data-refs.c13
5 files changed, 31 insertions, 16 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 8a0dc89cce3..a419f02e2a5 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,10 @@
2018-01-05 Richard Sandiford <richard.sandiford@linaro.org>
+ * tree-vect-data-refs.c (vect_compute_data_ref_alignment): Don't
+ punt for user-aligned variables.
+
+2018-01-05 Richard Sandiford <richard.sandiford@linaro.org>
+
* tree-chrec.c (chrec_contains_symbols): Return true for
POLY_INT_CST.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 5f1c7716415..2a18e22131f 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2018-01-05 Richard Sandiford <richard.sandiford@linaro.org>
+
+ * 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.
+
2018-01-05 Sudakshina Das <sudi.das@arm.com>
PR target/82439
diff --git a/gcc/testsuite/gcc.dg/vect/vect-align-4.c b/gcc/testsuite/gcc.dg/vect/vect-align-4.c
new file mode 100644
index 00000000000..82bbf07c568
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-align-4.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target vect_int } */
+/* { dg-add-options bind_pic_locally } */
+
+__attribute__((aligned (8))) int a[2048] = {};
+
+void
+f1 (void)
+{
+ for (int i = 0; i < 2048; i++)
+ a[i]++;
+}
+
+/* { dg-final { scan-tree-dump-not "Vectorizing an unaligned access" "vect" } } */
+/* { dg-final { scan-tree-dump-not "Alignment of access forced using peeling" "vect" } } */
diff --git a/gcc/testsuite/gcc.dg/vect/vect-nb-iter-ub-2.c b/gcc/testsuite/gcc.dg/vect/vect-nb-iter-ub-2.c
index 4e13702621f..229ce987db5 100644
--- a/gcc/testsuite/gcc.dg/vect/vect-nb-iter-ub-2.c
+++ b/gcc/testsuite/gcc.dg/vect/vect-nb-iter-ub-2.c
@@ -3,18 +3,19 @@
#include "tree-vect.h"
int ii[32];
-char cc[66] __attribute__((aligned(1))) =
+struct { char a; char b[66]; } cc = { 0,
{ 0, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0,
10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, 0, 16, 0, 17, 0, 18, 0, 19, 0,
20, 0, 21, 0, 22, 0, 23, 0, 24, 0, 25, 0, 26, 0, 27, 0, 28, 0, 29, 0,
- 30, 0, 31, 0 };
+ 30, 0, 31, 0 }
+};
void __attribute__((noinline,noclone))
foo (int s)
{
int i;
for (i = 0; i < s; i++)
- ii[i] = (int) cc[i*2];
+ ii[i] = (int) cc.b[i*2];
}
int main (int argc, const char **argv)
diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c
index 26431203f11..e0a2f7b7c89 100644
--- a/gcc/tree-vect-data-refs.c
+++ b/gcc/tree-vect-data-refs.c
@@ -920,19 +920,6 @@ vect_compute_data_ref_alignment (struct data_reference *dr)
return true;
}
- if (DECL_USER_ALIGN (base))
- {
- if (dump_enabled_p ())
- {
- dump_printf_loc (MSG_NOTE, vect_location,
- "not forcing alignment of user-aligned "
- "variable: ");
- dump_generic_expr (MSG_NOTE, TDF_SLIM, base);
- dump_printf (MSG_NOTE, "\n");
- }
- return true;
- }
-
/* Force the alignment of the decl.
NOTE: This is the only change to the code we make during
the analysis phase, before deciding to vectorize the loop. */