aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-data-ref.c
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@linaro.org>2017-07-03 13:37:07 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2017-07-03 13:37:07 +0000
commit25f68d908ff41a912a9bacb88afba665dd59c2ff (patch)
tree67ac693ded20cc4120dbf6e06c393b0918f0e88a /gcc/tree-data-ref.c
parentbb64297941f34721c7d4e94e754b454086511cf9 (diff)
downloadgcc-25f68d908ff41a912a9bacb88afba665dd59c2ff.zip
gcc-25f68d908ff41a912a9bacb88afba665dd59c2ff.tar.gz
gcc-25f68d908ff41a912a9bacb88afba665dd59c2ff.tar.bz2
Add a helper for getting the overall alignment of a DR
This combines the information from previous patches to give a guaranteed alignment for the DR as a whole. This should be a bit safer than using base_element_aligned, since that only really took the base into account (not the init or offset). 2017-07-03 Richard Sandiford <richard.sandiford@linaro.org> gcc/ * tree-data-ref.h (dr_alignment): Declare. * tree-data-ref.c (dr_alignment): New function. * tree-vectorizer.h (dataref_aux): Remove base_element_aligned. * tree-vect-data-refs.c (vect_compute_data_ref_alignment): Don't set it. * tree-vect-stmts.c (vectorizable_store): Use dr_alignment. From-SVN: r249917
Diffstat (limited to 'gcc/tree-data-ref.c')
-rw-r--r--gcc/tree-data-ref.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c
index ab76853..b7f9a57 100644
--- a/gcc/tree-data-ref.c
+++ b/gcc/tree-data-ref.c
@@ -4770,6 +4770,30 @@ find_data_references_in_loop (struct loop *loop,
return NULL_TREE;
}
+/* Return the alignment in bytes that DRB is guaranteed to have at all
+ times. */
+
+unsigned int
+dr_alignment (innermost_loop_behavior *drb)
+{
+ /* Get the alignment of BASE_ADDRESS + INIT. */
+ unsigned int alignment = drb->base_alignment;
+ unsigned int misalignment = (drb->base_misalignment
+ + TREE_INT_CST_LOW (drb->init));
+ if (misalignment != 0)
+ alignment = MIN (alignment, misalignment & -misalignment);
+
+ /* Cap it to the alignment of OFFSET. */
+ if (!integer_zerop (drb->offset))
+ alignment = MIN (alignment, drb->offset_alignment);
+
+ /* Cap it to the alignment of STEP. */
+ if (!integer_zerop (drb->step))
+ alignment = MIN (alignment, drb->step_alignment);
+
+ return alignment;
+}
+
/* Recursive helper function. */
static bool