From: Jakub Jelinek Date: Sat, 4 Feb 2017 07:44:13 +0000 (+0100) Subject: re PR tree-optimization/79338 (Memory leak in tree-parloops.c) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=846b1a180747f8c4c3ba790607d9f457de0d3570;p=gcc.git re PR tree-optimization/79338 (Memory leak in tree-parloops.c) PR tree-optimization/79338 * tree-parloops.c (gather_scalar_reductions): Don't call vect_analyze_loop_form for loop->inner before destroying loop's loop_vinfo. From-SVN: r245183 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 40993e5a0dd..3be3f745994 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2017-02-04 Jakub Jelinek + + PR tree-optimization/79338 + * tree-parloops.c (gather_scalar_reductions): Don't call + vect_analyze_loop_form for loop->inner before destroying loop's + loop_vinfo. + 2017-02-03 Martin Sebor PR tree-optimization/79327 diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c index 779258b90b4..83aa8308def 100644 --- a/gcc/tree-parloops.c +++ b/gcc/tree-parloops.c @@ -2513,8 +2513,8 @@ gather_scalar_reductions (loop_p loop, reduction_info_table_type *reduction_list { gphi_iterator gsi; loop_vec_info simple_loop_info; - loop_vec_info simple_inner_loop_info = NULL; - bool allow_double_reduc = true; + auto_vec double_reduc_phis; + auto_vec double_reduc_stmts; if (!stmt_vec_info_vec.exists ()) init_stmt_vec_info_vec (); @@ -2544,43 +2544,55 @@ gather_scalar_reductions (loop_p loop, reduction_info_table_type *reduction_list if (double_reduc) { - if (!allow_double_reduc - || loop->inner->inner != NULL) + if (loop->inner->inner != NULL) continue; - if (!simple_inner_loop_info) - { - simple_inner_loop_info = vect_analyze_loop_form (loop->inner); - if (!simple_inner_loop_info) - { - allow_double_reduc = false; - continue; - } - } - - use_operand_p use_p; - gimple *inner_stmt; - bool single_use_p = single_imm_use (res, &use_p, &inner_stmt); - gcc_assert (single_use_p); - if (gimple_code (inner_stmt) != GIMPLE_PHI) - continue; - gphi *inner_phi = as_a (inner_stmt); - if (simple_iv (loop->inner, loop->inner, PHI_RESULT (inner_phi), - &iv, true)) - continue; - - gimple *inner_reduc_stmt - = vect_force_simple_reduction (simple_inner_loop_info, inner_phi, - true, &double_reduc, true); - gcc_assert (!double_reduc); - if (inner_reduc_stmt == NULL) - continue; + double_reduc_phis.safe_push (phi); + double_reduc_stmts.safe_push (reduc_stmt); + continue; } build_new_reduction (reduction_list, reduc_stmt, phi); } destroy_loop_vec_info (simple_loop_info, true); - destroy_loop_vec_info (simple_inner_loop_info, true); + + if (!double_reduc_phis.is_empty ()) + { + simple_loop_info = vect_analyze_loop_form (loop->inner); + if (simple_loop_info) + { + gphi *phi; + unsigned int i; + + FOR_EACH_VEC_ELT (double_reduc_phis, i, phi) + { + affine_iv iv; + tree res = PHI_RESULT (phi); + bool double_reduc; + + use_operand_p use_p; + gimple *inner_stmt; + bool single_use_p = single_imm_use (res, &use_p, &inner_stmt); + gcc_assert (single_use_p); + if (gimple_code (inner_stmt) != GIMPLE_PHI) + continue; + gphi *inner_phi = as_a (inner_stmt); + if (simple_iv (loop->inner, loop->inner, PHI_RESULT (inner_phi), + &iv, true)) + continue; + + gimple *inner_reduc_stmt + = vect_force_simple_reduction (simple_loop_info, inner_phi, + true, &double_reduc, true); + gcc_assert (!double_reduc); + if (inner_reduc_stmt == NULL) + continue; + + build_new_reduction (reduction_list, double_reduc_stmts[i], phi); + } + destroy_loop_vec_info (simple_loop_info, true); + } + } gather_done: /* Release the claim on gimple_uid. */