dump_generic_expr (MSG_NOTE, TDF_SLIM, access_fn);
dump_printf (MSG_NOTE, "\n");
}
+ STMT_VINFO_LOOP_PHI_EVOLUTION_BASE_UNCHANGED (stmt_vinfo)
+ = initial_condition_in_loop_num (access_fn, loop->num);
STMT_VINFO_LOOP_PHI_EVOLUTION_PART (stmt_vinfo)
= evolution_part_in_loop_num (access_fn, loop->num);
}
continue;
}
+ gcc_assert (STMT_VINFO_LOOP_PHI_EVOLUTION_BASE_UNCHANGED (stmt_vinfo)
+ != NULL_TREE);
gcc_assert (STMT_VINFO_LOOP_PHI_EVOLUTION_PART (stmt_vinfo) != NULL_TREE);
if (dump_enabled_p ())
is_nonwrapping_integer_induction (gimple *stmt, struct loop *loop)
{
stmt_vec_info stmt_vinfo = vinfo_for_stmt (stmt);
- tree base = PHI_ARG_DEF_FROM_EDGE (stmt, loop_preheader_edge (loop));
+ tree base = STMT_VINFO_LOOP_PHI_EVOLUTION_BASE_UNCHANGED (stmt_vinfo);
tree step = STMT_VINFO_LOOP_PHI_EVOLUTION_PART (stmt_vinfo);
tree lhs_type = TREE_TYPE (gimple_phi_result (stmt));
widest_int ni, max_loop_value, lhs_max;
tree def0, def1, tem, op0, op1 = NULL_TREE;
bool first_p = true;
tree cr_index_scalar_type = NULL_TREE, cr_index_vector_type = NULL_TREE;
- bool cond_expr_is_nonwrapping_integer_induction = false;
+ gimple *cond_expr_induction_def_stmt = NULL;
/* In case of reduction chain we switch to the first stmt in the chain, but
we don't update STMT_INFO, since only the last stmt is marked as reduction
reduc_index = i;
}
- if (i == 1 && code == COND_EXPR && dt == vect_induction_def
- && is_nonwrapping_integer_induction (def_stmt, loop))
- {
- if (dump_enabled_p ())
- dump_printf_loc (MSG_NOTE, vect_location,
- "condition expression based on integer "
- "induction.\n");
- cond_expr_is_nonwrapping_integer_induction = true;
- }
+ if (i == 1 && code == COND_EXPR && dt == vect_induction_def)
+ cond_expr_induction_def_stmt = def_stmt;
}
is_simple_use = vect_is_simple_use (ops[reduc_index], loop_vinfo,
return false;
}
- gimple *tmp = vect_is_simple_reduction
- (loop_vinfo, reduc_def_stmt,
- !nested_cycle, &dummy, false,
- &STMT_VINFO_VEC_REDUCTION_TYPE (stmt_info));
+ enum vect_reduction_type v_reduc_type;
+ gimple *tmp = vect_is_simple_reduction (loop_vinfo, reduc_def_stmt,
+ !nested_cycle, &dummy, false,
+ &v_reduc_type);
- if (cond_expr_is_nonwrapping_integer_induction
- && STMT_VINFO_VEC_REDUCTION_TYPE (stmt_info) == COND_REDUCTION)
- STMT_VINFO_VEC_REDUCTION_TYPE (stmt_info) = INTEGER_INDUC_COND_REDUCTION;
+ /* If we have a condition reduction, see if we can simplify it further. */
+ if (v_reduc_type == COND_REDUCTION
+ && cond_expr_induction_def_stmt != NULL
+ && is_nonwrapping_integer_induction (cond_expr_induction_def_stmt, loop))
+ {
+ if (dump_enabled_p ())
+ dump_printf_loc (MSG_NOTE, vect_location,
+ "condition expression based on integer induction.\n");
+ STMT_VINFO_VEC_REDUCTION_TYPE (stmt_info) = INTEGER_INDUC_COND_REDUCTION;
+ }
+ else
+ STMT_VINFO_VEC_REDUCTION_TYPE (stmt_info) = v_reduc_type;
if (orig_stmt)
gcc_assert (tmp == orig_stmt
tree dr_step;
tree dr_aligned_to;
- /* For loop PHI nodes, the evolution part of it. This makes sure
+ /* For loop PHI nodes, the base and evolution part of it. This makes sure
this information is still available in vect_update_ivs_after_vectorizer
where we may not be able to re-analyze the PHI nodes evolution as
peeling for the prologue loop can make it unanalyzable. The evolution
- part is still correct though. */
+ part is still correct after peeling, but the base may have changed from
+ the version here. */
+ tree loop_phi_evolution_base_unchanged;
tree loop_phi_evolution_part;
/* Used for various bookkeeping purposes, generally holding a pointer to
#define STMT_VINFO_GROUP_GAP(S) (S)->gap
#define STMT_VINFO_GROUP_SAME_DR_STMT(S) (S)->same_dr_stmt
#define STMT_VINFO_GROUPED_ACCESS(S) ((S)->first_element != NULL && (S)->data_ref_info)
+#define STMT_VINFO_LOOP_PHI_EVOLUTION_BASE_UNCHANGED(S) (S)->loop_phi_evolution_base_unchanged
#define STMT_VINFO_LOOP_PHI_EVOLUTION_PART(S) (S)->loop_phi_evolution_part
#define STMT_VINFO_MIN_NEG_DIST(S) (S)->min_neg_dist