aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-vect-loop-manip.c
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2011-05-12 12:14:45 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2011-05-12 12:14:45 +0000
commite2a3a5f1add296430b85b6b6be24b7340a7bcc9e (patch)
treecf899c907f573aea77afa842e6421886a7bacd7d /gcc/tree-vect-loop-manip.c
parent2c703f3a6a2a283318a0678fc8a5eba27b6663df (diff)
downloadgcc-e2a3a5f1add296430b85b6b6be24b7340a7bcc9e.zip
gcc-e2a3a5f1add296430b85b6b6be24b7340a7bcc9e.tar.gz
gcc-e2a3a5f1add296430b85b6b6be24b7340a7bcc9e.tar.bz2
re PR tree-optimization/48172 (incorrect vectorization of loop in GCC 4.5.* with -O3)
2011-05-12 Richard Guenther <rguenther@suse.de> PR tree-optimization/48172 * tree-vect-loop-manip.c (vect_vfa_segment_size): Do not exclude the number of iterations from the segment size calculation. (vect_create_cond_for_alias_checks): Adjust. * gcc.dg/vect/pr48172.c: New testcase. From-SVN: r173703
Diffstat (limited to 'gcc/tree-vect-loop-manip.c')
-rw-r--r--gcc/tree-vect-loop-manip.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/gcc/tree-vect-loop-manip.c b/gcc/tree-vect-loop-manip.c
index 28b75f1..d990e7f 100644
--- a/gcc/tree-vect-loop-manip.c
+++ b/gcc/tree-vect-loop-manip.c
@@ -2354,26 +2354,31 @@ vect_create_cond_for_align_checks (loop_vec_info loop_vinfo,
Input:
DR: The data reference.
VECT_FACTOR: vectorization factor.
+ SCALAR_LOOP_NITERS: number of iterations.
Return an expression whose value is the size of segment which will be
accessed by DR. */
static tree
-vect_vfa_segment_size (struct data_reference *dr, tree vect_factor)
+vect_vfa_segment_size (struct data_reference *dr, int vect_factor,
+ tree scalar_loop_niters)
{
- tree segment_length = fold_build2 (MULT_EXPR, integer_type_node,
- DR_STEP (dr), vect_factor);
-
+ tree segment_length;
+ segment_length = size_binop (MULT_EXPR,
+ fold_convert (sizetype, DR_STEP (dr)),
+ size_int (vect_factor));
+ segment_length = size_binop (MULT_EXPR,
+ segment_length,
+ fold_convert (sizetype, scalar_loop_niters));
if (vect_supportable_dr_alignment (dr, false)
== dr_explicit_realign_optimized)
{
tree vector_size = TYPE_SIZE_UNIT
(STMT_VINFO_VECTYPE (vinfo_for_stmt (DR_STMT (dr))));
- segment_length = fold_build2 (PLUS_EXPR, integer_type_node,
- segment_length, vector_size);
+ segment_length = size_binop (PLUS_EXPR, segment_length, vector_size);
}
- return fold_convert (sizetype, segment_length);
+ return segment_length;
}
@@ -2407,8 +2412,8 @@ vect_create_cond_for_alias_checks (loop_vec_info loop_vinfo,
struct loop *loop = LOOP_VINFO_LOOP (loop_vinfo);
VEC (ddr_p, heap) * may_alias_ddrs =
LOOP_VINFO_MAY_ALIAS_DDRS (loop_vinfo);
- tree vect_factor =
- build_int_cst (integer_type_node, LOOP_VINFO_VECT_FACTOR (loop_vinfo));
+ int vect_factor = LOOP_VINFO_VECT_FACTOR (loop_vinfo);
+ tree scalar_loop_iters = LOOP_VINFO_NITERS (loop_vinfo);
ddr_p ddr;
unsigned int i;
@@ -2460,8 +2465,10 @@ vect_create_cond_for_alias_checks (loop_vec_info loop_vinfo,
vect_create_addr_base_for_vector_ref (stmt_b, cond_expr_stmt_list,
NULL_TREE, loop);
- segment_length_a = vect_vfa_segment_size (dr_a, vect_factor);
- segment_length_b = vect_vfa_segment_size (dr_b, vect_factor);
+ segment_length_a = vect_vfa_segment_size (dr_a, vect_factor,
+ scalar_loop_iters);
+ segment_length_b = vect_vfa_segment_size (dr_b, vect_factor,
+ scalar_loop_iters);
if (vect_print_dump_info (REPORT_DR_DETAILS))
{