aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-vect-data-refs.c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2013-04-11 11:21:18 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2013-04-11 11:21:18 +0000
commit4ba5ea117ac17ad00bb26b2cb64588ae345a6491 (patch)
tree7131ce4ad93149ef59b657a80ec5ada7b65d7fb4 /gcc/tree-vect-data-refs.c
parent983a3d80db525e9d7fbba6f222d3030bfc0a68ac (diff)
downloadgcc-4ba5ea117ac17ad00bb26b2cb64588ae345a6491.zip
gcc-4ba5ea117ac17ad00bb26b2cb64588ae345a6491.tar.gz
gcc-4ba5ea117ac17ad00bb26b2cb64588ae345a6491.tar.bz2
re PR tree-optimization/56878 (Issue with candidate choice in vect_gen_niters_for_prolog_loop.)
2013-04-11 Richard Biener <rguenther@suse.de> PR tree-optimization/56878 * tree-flow.h (outermost_invariant_loop_for_expr): Declare. * tree-ssa-loop-ivopts.c (outermost_invariant_loop_for_expr): New function. * tree-vect-data-refs.c (vect_enhance_data_refs_alignment): Prefer to align the DR with the most invariant base address. From-SVN: r197769
Diffstat (limited to 'gcc/tree-vect-data-refs.c')
-rw-r--r--gcc/tree-vect-data-refs.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c
index e20ab1f..64f2a8b 100644
--- a/gcc/tree-vect-data-refs.c
+++ b/gcc/tree-vect-data-refs.c
@@ -1456,20 +1456,35 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo)
}
else
{
- /* If we don't know all the misalignment values, we prefer
- peeling for data-ref that has maximum number of data-refs
+ /* If we don't know any misalignment values, we prefer
+ peeling for data-ref that has the maximum number of data-refs
with the same alignment, unless the target prefers to align
stores over load. */
if (all_misalignments_unknown)
{
- if (same_align_drs_max
- < STMT_VINFO_SAME_ALIGN_REFS (stmt_info).length ()
- || !dr0)
+ unsigned same_align_drs
+ = STMT_VINFO_SAME_ALIGN_REFS (stmt_info).length ();
+ if (!dr0
+ || same_align_drs_max < same_align_drs)
{
- same_align_drs_max
- = STMT_VINFO_SAME_ALIGN_REFS (stmt_info).length ();
+ same_align_drs_max = same_align_drs;
dr0 = dr;
}
+ /* For data-refs with the same number of related
+ accesses prefer the one where the misalign
+ computation will be invariant in the outermost loop. */
+ else if (same_align_drs_max == same_align_drs)
+ {
+ struct loop *ivloop0, *ivloop;
+ ivloop0 = outermost_invariant_loop_for_expr
+ (loop, DR_BASE_ADDRESS (dr0));
+ ivloop = outermost_invariant_loop_for_expr
+ (loop, DR_BASE_ADDRESS (dr));
+ if ((ivloop && !ivloop0)
+ || (ivloop && ivloop0
+ && flow_loop_nested_p (ivloop, ivloop0)))
+ dr0 = dr;
+ }
if (!first_store && DR_IS_WRITE (dr))
first_store = dr;
@@ -1478,8 +1493,6 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo)
/* If there are both known and unknown misaligned accesses in the
loop, we choose peeling amount according to the known
accesses. */
-
-
if (!supportable_dr_alignment)
{
dr0 = dr;