@@ -1072,6 +1072,7 @@ _loop_vec_info::_loop_vec_info (class loop *loop_in, vec_info_shared *shared)
scalar_loop_scaling (profile_probability::uninitialized ()),
scalar_loop (NULL),
orig_loop_info (NULL),
+ drs_advanced_by (NULL_TREE),
vec_loop_iv_exit (NULL),
vec_epilogue_loop_iv_exit (NULL),
scalar_loop_iv_exit (NULL)
@@ -12302,6 +12303,9 @@ update_epilogue_loop_vinfo (class loop *epilogue, tree advance)
loop and its prologue. */
vect_update_inits_of_drs (epilogue_vinfo, advance, PLUS_EXPR);
+ /* Remember the advancement made. */
+ LOOP_VINFO_DRS_ADVANCED_BY (epilogue_vinfo) = advance;
+
epilogue_vinfo->shared->datarefs_copy.release ();
epilogue_vinfo->shared->save_datarefs ();
}
@@ -12849,6 +12853,11 @@ vect_transform_loop (loop_vec_info loop_vinfo, gimple *loop_vectorized_call)
if (epilogue)
{
+ /* Accumulate past advancements made. */
+ if (LOOP_VINFO_DRS_ADVANCED_BY (loop_vinfo))
+ advance = fold_build2 (PLUS_EXPR, TREE_TYPE (advance),
+ LOOP_VINFO_DRS_ADVANCED_BY (loop_vinfo),
+ advance);
update_epilogue_loop_vinfo (epilogue, advance);
epilogue->simduid = loop->simduid;
@@ -994,6 +994,9 @@ public:
analysis. */
vec<_loop_vec_info *> epilogue_vinfos;
+ /* If this is an epilogue loop the DR advancement applied. */
+ tree drs_advanced_by;
+
/* The controlling loop IV for the current loop when vectorizing. This IV
controls the natural exits of the loop. */
edge vec_loop_iv_exit;
@@ -1097,6 +1100,7 @@ public:
#define LOOP_VINFO_SIMD_IF_COND(L) (L)->simd_if_cond
#define LOOP_VINFO_INNER_LOOP_COST_FACTOR(L) (L)->inner_loop_cost_factor
#define LOOP_VINFO_INV_PATTERN_DEF_SEQ(L) (L)->inv_pattern_def_seq
+#define LOOP_VINFO_DRS_ADVANCED_BY(L) (L)->drs_advanced_by
#define LOOP_VINFO_FULLY_MASKED_P(L) \
(LOOP_VINFO_USING_PARTIAL_VECTORS_P (L) \