From: Richard Biener Date: Mon, 26 Oct 2020 09:08:38 +0000 (+0100) Subject: tree-optimization/97539 - reset out-of-loop debug uses before peeling X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=27c14056f4805c9d8cfc655ef2c846be128b02c9;p=gcc.git tree-optimization/97539 - reset out-of-loop debug uses before peeling This makes sure to reset out-of-loop debug uses before vectorizer loop peeling as we cannot make sure to retain the use-def dominance relationship when there are no LC SSA nodes. 2020-10-26 Richard Biener PR tree-optimization/97539 * tree-vect-loop-manip.c (vect_do_peeling): Reset out-of-loop debug uses before peeling. * gcc.dg/pr97539.c: New testcase. --- diff --git a/gcc/testsuite/gcc.dg/pr97539.c b/gcc/testsuite/gcc.dg/pr97539.c new file mode 100644 index 00000000000..def55e1d6ee --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr97539.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -g" } */ + +int a, b; +void c() { + char d; + for (; b;) + for (;;) + for (; d <= 7; d += 1) { + a = 7; + for (; a; a += 1) + e: + d += d; + d ^= 0; + } + goto e; +} diff --git a/gcc/tree-vect-loop-manip.c b/gcc/tree-vect-loop-manip.c index 7cf00e6eed4..5d00b6fb956 100644 --- a/gcc/tree-vect-loop-manip.c +++ b/gcc/tree-vect-loop-manip.c @@ -2545,6 +2545,45 @@ vect_do_peeling (loop_vec_info loop_vinfo, tree niters, tree nitersm1, if (!prolog_peeling && !epilog_peeling) return NULL; + /* Before doing any peeling make sure to reset debug binds outside of + the loop refering to defs not in LC SSA. */ + class loop *loop = LOOP_VINFO_LOOP (loop_vinfo); + for (unsigned i = 0; i < loop->num_nodes; ++i) + { + basic_block bb = LOOP_VINFO_BBS (loop_vinfo)[i]; + imm_use_iterator ui; + gimple *use_stmt; + for (gphi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi); + gsi_next (&gsi)) + { + FOR_EACH_IMM_USE_STMT (use_stmt, ui, gimple_phi_result (gsi.phi ())) + if (gimple_debug_bind_p (use_stmt) + && loop != gimple_bb (use_stmt)->loop_father + && !flow_loop_nested_p (loop, + gimple_bb (use_stmt)->loop_father)) + { + gimple_debug_bind_reset_value (use_stmt); + update_stmt (use_stmt); + } + } + for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi); + gsi_next (&gsi)) + { + ssa_op_iter op_iter; + def_operand_p def_p; + FOR_EACH_SSA_DEF_OPERAND (def_p, gsi_stmt (gsi), op_iter, SSA_OP_DEF) + FOR_EACH_IMM_USE_STMT (use_stmt, ui, DEF_FROM_PTR (def_p)) + if (gimple_debug_bind_p (use_stmt) + && loop != gimple_bb (use_stmt)->loop_father + && !flow_loop_nested_p (loop, + gimple_bb (use_stmt)->loop_father)) + { + gimple_debug_bind_reset_value (use_stmt); + update_stmt (use_stmt); + } + } + } + prob_vector = profile_probability::guessed_always ().apply_scale (9, 10); estimated_vf = vect_vf_for_cost (loop_vinfo); if (estimated_vf == 2) @@ -2552,7 +2591,7 @@ vect_do_peeling (loop_vec_info loop_vinfo, tree niters, tree nitersm1, prob_prolog = prob_epilog = profile_probability::guessed_always () .apply_scale (estimated_vf - 1, estimated_vf); - class loop *prolog, *epilog = NULL, *loop = LOOP_VINFO_LOOP (loop_vinfo); + class loop *prolog, *epilog = NULL; class loop *first_loop = loop; bool irred_flag = loop_preheader_edge (loop)->flags & EDGE_IRREDUCIBLE_LOOP;