diff options
author | Andrew Hsieh <andrewhsieh@google.com> | 2014-06-20 13:50:27 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2014-06-20 02:04:52 +0000 |
commit | 3c447213baf828ebd01c45ad459552b3c9922c92 (patch) | |
tree | 198ed6386925c6ff5c24faf686b836aa74082836 /gcc-4.8/gcc/tree-vect-loop.c | |
parent | e1be674a8e345aaa025ad9f1d38bab4272301e1d (diff) | |
parent | f190d6284359da8ae8694b2d2e14b01602a959ed (diff) | |
download | toolchain_gcc-3c447213baf828ebd01c45ad459552b3c9922c92.tar.gz toolchain_gcc-3c447213baf828ebd01c45ad459552b3c9922c92.tar.bz2 toolchain_gcc-3c447213baf828ebd01c45ad459552b3c9922c92.zip |
Merge "Merge GCC 4.8.3"
Diffstat (limited to 'gcc-4.8/gcc/tree-vect-loop.c')
-rw-r--r-- | gcc-4.8/gcc/tree-vect-loop.c | 61 |
1 files changed, 38 insertions, 23 deletions
diff --git a/gcc-4.8/gcc/tree-vect-loop.c b/gcc-4.8/gcc/tree-vect-loop.c index ce531e137..7daa8c133 100644 --- a/gcc-4.8/gcc/tree-vect-loop.c +++ b/gcc-4.8/gcc/tree-vect-loop.c @@ -1537,7 +1537,7 @@ vect_analyze_loop_operations (loop_vec_info loop_vinfo, bool slp) if (!LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo) || LOOP_VINFO_INT_NITERS (loop_vinfo) % vectorization_factor != 0 - || LOOP_PEELING_FOR_ALIGNMENT (loop_vinfo)) + || LOOP_VINFO_PEELING_FOR_GAPS (loop_vinfo)) { if (dump_enabled_p ()) dump_printf_loc (MSG_NOTE, vect_location, "epilog loop required."); @@ -2097,6 +2097,12 @@ vect_is_simple_reduction_1 (loop_vec_info loop_info, gimple phi, || (!check_reduction && flow_loop_nested_p (vect_loop, loop))); name = PHI_RESULT (phi); + /* ??? If there are no uses of the PHI result the inner loop reduction + won't be detected as possibly double-reduction by vectorizable_reduction + because that tries to walk the PHI arg from the preheader edge which + can be constant. See PR60382. */ + if (has_zero_uses (name)) + return NULL; nloop_uses = 0; FOR_EACH_IMM_USE_FAST (use_p, imm_iter, name) { @@ -3115,14 +3121,12 @@ get_initial_def_for_induction (gimple iv_phi) stmt_vec_info stmt_vinfo = vinfo_for_stmt (iv_phi); loop_vec_info loop_vinfo = STMT_VINFO_LOOP_VINFO (stmt_vinfo); struct loop *loop = LOOP_VINFO_LOOP (loop_vinfo); - tree scalar_type; tree vectype; int nunits; edge pe = loop_preheader_edge (loop); struct loop *iv_loop; basic_block new_bb; tree new_vec, vec_init, vec_step, t; - tree access_fn; tree new_var; tree new_name; gimple init_stmt, induction_phi, new_stmt; @@ -3130,7 +3134,6 @@ get_initial_def_for_induction (gimple iv_phi) tree init_expr, step_expr; int vf = LOOP_VINFO_VECT_FACTOR (loop_vinfo); int i; - bool ok; int ncopies; tree expr; stmt_vec_info phi_info = vinfo_for_stmt (iv_phi); @@ -3159,16 +3162,14 @@ get_initial_def_for_induction (gimple iv_phi) latch_e = loop_latch_edge (iv_loop); loop_arg = PHI_ARG_DEF_FROM_EDGE (iv_phi, latch_e); - access_fn = analyze_scalar_evolution (iv_loop, PHI_RESULT (iv_phi)); - gcc_assert (access_fn); - STRIP_NOPS (access_fn); - ok = vect_is_simple_iv_evolution (iv_loop->num, access_fn, - &init_expr, &step_expr); - gcc_assert (ok); + step_expr = STMT_VINFO_LOOP_PHI_EVOLUTION_PART (phi_info); + gcc_assert (step_expr != NULL_TREE); + pe = loop_preheader_edge (iv_loop); + init_expr = PHI_ARG_DEF_FROM_EDGE (iv_phi, + loop_preheader_edge (iv_loop)); - scalar_type = TREE_TYPE (init_expr); - vectype = get_vectype_for_scalar_type (scalar_type); + vectype = get_vectype_for_scalar_type (TREE_TYPE (init_expr)); resvectype = get_vectype_for_scalar_type (TREE_TYPE (PHI_RESULT (iv_phi))); gcc_assert (vectype); nunits = TYPE_VECTOR_SUBPARTS (vectype); @@ -3177,6 +3178,16 @@ get_initial_def_for_induction (gimple iv_phi) gcc_assert (phi_info); gcc_assert (ncopies >= 1); + /* Convert the step to the desired type. */ + step_expr = force_gimple_operand (fold_convert (TREE_TYPE (vectype), + step_expr), + &stmts, true, NULL_TREE); + if (stmts) + { + new_bb = gsi_insert_seq_on_edge_immediate (pe, stmts); + gcc_assert (!new_bb); + } + /* Find the first insertion point in the BB. */ si = gsi_after_labels (bb); @@ -3186,9 +3197,7 @@ get_initial_def_for_induction (gimple iv_phi) /* iv_loop is nested in the loop to be vectorized. init_expr had already been created during vectorization of previous stmts. We obtain it from the STMT_VINFO_VEC_STMT of the defining stmt. */ - tree iv_def = PHI_ARG_DEF_FROM_EDGE (iv_phi, - loop_preheader_edge (iv_loop)); - vec_init = vect_get_vec_def_for_operand (iv_def, iv_phi, NULL); + vec_init = vect_get_vec_def_for_operand (init_expr, iv_phi, NULL); /* If the initial value is not of proper type, convert it. */ if (!useless_type_conversion_p (vectype, TREE_TYPE (vec_init))) { @@ -3211,8 +3220,11 @@ get_initial_def_for_induction (gimple iv_phi) /* iv_loop is the loop to be vectorized. Create: vec_init = [X, X+S, X+2*S, X+3*S] (S = step_expr, X = init_expr) */ - new_var = vect_get_new_vect_var (scalar_type, vect_scalar_var, "var_"); - new_name = force_gimple_operand (init_expr, &stmts, false, new_var); + new_var = vect_get_new_vect_var (TREE_TYPE (vectype), + vect_scalar_var, "var_"); + new_name = force_gimple_operand (fold_convert (TREE_TYPE (vectype), + init_expr), + &stmts, false, new_var); if (stmts) { new_bb = gsi_insert_seq_on_edge_immediate (pe, stmts); @@ -3224,9 +3236,7 @@ get_initial_def_for_induction (gimple iv_phi) for (i = 1; i < nunits; i++) { /* Create: new_name_i = new_name + step_expr */ - enum tree_code code = POINTER_TYPE_P (scalar_type) - ? POINTER_PLUS_EXPR : PLUS_EXPR; - init_stmt = gimple_build_assign_with_ops (code, new_var, + init_stmt = gimple_build_assign_with_ops (PLUS_EXPR, new_var, new_name, step_expr); new_name = make_ssa_name (new_var, init_stmt); gimple_assign_set_lhs (init_stmt, new_name); @@ -3781,8 +3791,12 @@ vect_create_epilog_for_reduction (vec<tree> vect_defs, gimple stmt, /* Set phi nodes arguments. */ FOR_EACH_VEC_ELT (reduction_phis, i, phi) { - tree vec_init_def = vec_initial_defs[i]; - tree def = vect_defs[i]; + tree vec_init_def, def; + gimple_seq stmts; + vec_init_def = force_gimple_operand (vec_initial_defs[i], &stmts, + true, NULL_TREE); + gsi_insert_seq_on_edge_immediate (loop_preheader_edge (loop), stmts); + def = vect_defs[i]; for (j = 0; j < ncopies; j++) { /* Set the loop-entry arg of the reduction-phi. */ @@ -5564,7 +5578,8 @@ vect_transform_loop (loop_vec_info loop_vinfo) && !STMT_VINFO_LIVE_P (stmt_info)) continue; - if ((TYPE_VECTOR_SUBPARTS (STMT_VINFO_VECTYPE (stmt_info)) + if (STMT_VINFO_VECTYPE (stmt_info) + && (TYPE_VECTOR_SUBPARTS (STMT_VINFO_VECTYPE (stmt_info)) != (unsigned HOST_WIDE_INT) vectorization_factor) && dump_enabled_p ()) dump_printf_loc (MSG_NOTE, vect_location, "multiple-types."); |