From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 76589 invoked by alias); 31 Jul 2018 12:05:40 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 76558 invoked by uid 89); 31 Jul 2018 12:05:39 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.0 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_2,GIT_PATCH_3,KAM_ASCII_DIVIDERS,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-lj1-f172.google.com Received: from mail-lj1-f172.google.com (HELO mail-lj1-f172.google.com) (209.85.208.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 31 Jul 2018 12:05:37 +0000 Received: by mail-lj1-f172.google.com with SMTP id j19-v6so13464974ljc.7 for ; Tue, 31 Jul 2018 05:05:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=bGL45Bm+NWs5ADS04DnfND+eSueOK6RlxUitTZYSKJo=; b=Jv2iE00+v/31eVePj30su0VBVDDLrByFubRMuyA2bdFVqVzckTSvbia3XXRD4OgnT6 PJOMU3cEG4lLGf3UCFBFLMbyX6H33r3cWXXAGasR68+RgkyxmvhJ9Ex+1mZ+ZHSaUPPr gbc7cbiNqKOgutZX5nbU4twVM9mwbySJomHUgXQBCEp0DTlac1+fNWHUiE05a9kPqb9s 3OHKatwikIOi8Z5JUPbZtwaibfLH7Cg5y3u7UvSOYJFhmJBNCNtzRUrmV6JY/eMR/8el nmwm7YP8YUDSQGmdq11REERAKf5cxH5l/ZoK84Ki/73Xds6U9HZrP6A3unxm/NYuEGeV qMdQ== MIME-Version: 1.0 References: <87wotlrmen.fsf@arm.com> <87muuhkkq3.fsf@arm.com> In-Reply-To: <87muuhkkq3.fsf@arm.com> From: Richard Biener Date: Tue, 31 Jul 2018 12:05:00 -0000 Message-ID: Subject: Re: [44/46] Remove global vinfo_for_stmt-related routines To: GCC Patches , richard.sandiford@arm.com Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2018-07/txt/msg01925.txt.bz2 On Tue, Jul 24, 2018 at 12:10 PM Richard Sandiford wrote: > > There are no more direct uses of: > > - new_stmt_vec_info > - set_vinfo_for_stmt > - free_stmt_vec_infos > - free_stmt_vec_info > > outside of vec_info, so they can now be private member functions. > It also seemed better to put them in tree-vectorizer.c, along with the > other vec_info routines. > > We can also get rid of: > > - vinfo_for_stmt > - stmt_vec_info_vec > - set_stmt_vec_info_vec > > since nothing now uses them. This was the main goal of the series. Great. OK. Thanks, Richard. > > 2018-07-24 Richard Sandiford > > gcc/ > * tree-vectorizer.h (vec_info::new_vinfo_for_stmt) > (vec_info::set_vinfo_for_stmt, vec_info::free_stmt_vec_infos) > (vec_info::free_stmt_vec_info): New private member functions. > (set_stmt_vec_info_vec, free_stmt_vec_infos, vinfo_for_stmt) > (set_vinfo_for_stmt, new_stmt_vec_info, free_stmt_vec_info): Delete. > * tree-parloops.c (gather_scalar_reductions): Remove calls to > set_stmt_vec_info_vec and free_stmt_vec_infos. > * tree-vect-loop.c (_loop_vec_info): Remove call to > set_stmt_vec_info_vec. > * tree-vect-stmts.c (new_stmt_vec_info, set_stmt_vec_info_vec) > (free_stmt_vec_infos, free_stmt_vec_info): Delete in favor of... > * tree-vectorizer.c (vec_info::new_stmt_vec_info) > (vec_info::set_vinfo_for_stmt, vec_info::free_stmt_vec_infos) > (vec_info::free_stmt_vec_info): ...these new functions. Remove > assignments in {vec_info::,}new_stmt_vec_info that are redundant > with the clearing in the xcalloc. > (stmt_vec_info_vec): Delete. > (vec_info::vec_info): Don't call set_stmt_vec_info_vec. > (vectorize_loops): Likewise. > (vec_info::~vec_info): Remove argument from call to > free_stmt_vec_infos. > (vec_info::add_stmt): Remove vinfo argument from call to > new_stmt_vec_info. > > Index: gcc/tree-vectorizer.h > =================================================================== > --- gcc/tree-vectorizer.h 2018-07-24 10:24:26.084281700 +0100 > +++ gcc/tree-vectorizer.h 2018-07-24 10:24:29.300253129 +0100 > @@ -266,6 +266,12 @@ struct vec_info { > > /* Cost data used by the target cost model. */ > void *target_cost_data; > + > +private: > + stmt_vec_info new_stmt_vec_info (gimple *stmt); > + void set_vinfo_for_stmt (gimple *, stmt_vec_info); > + void free_stmt_vec_infos (); > + void free_stmt_vec_info (stmt_vec_info); > }; > > struct _loop_vec_info; > @@ -1085,43 +1091,6 @@ inline stmt_vec_info::operator gimple * > return m_ptr ? m_ptr->stmt : NULL; > } > > -extern vec *stmt_vec_info_vec; > - > -void set_stmt_vec_info_vec (vec *); > -void free_stmt_vec_infos (vec *); > - > -/* Return a stmt_vec_info corresponding to STMT. */ > - > -static inline stmt_vec_info > -vinfo_for_stmt (gimple *stmt) > -{ > - int uid = gimple_uid (stmt); > - if (uid <= 0) > - return NULL; > - > - return (*stmt_vec_info_vec)[uid - 1]; > -} > - > -/* Set vectorizer information INFO for STMT. */ > - > -static inline void > -set_vinfo_for_stmt (gimple *stmt, stmt_vec_info info) > -{ > - unsigned int uid = gimple_uid (stmt); > - if (uid == 0) > - { > - gcc_checking_assert (info); > - uid = stmt_vec_info_vec->length () + 1; > - gimple_set_uid (stmt, uid); > - stmt_vec_info_vec->safe_push (info); > - } > - else > - { > - gcc_checking_assert (info == NULL_STMT_VEC_INFO); > - (*stmt_vec_info_vec)[uid - 1] = info; > - } > -} > - > static inline bool > nested_in_vect_loop_p (struct loop *loop, stmt_vec_info stmt_info) > { > @@ -1483,8 +1452,6 @@ extern bool supportable_widening_operati > extern bool supportable_narrowing_operation (enum tree_code, tree, tree, > enum tree_code *, > int *, vec *); > -extern stmt_vec_info new_stmt_vec_info (gimple *stmt, vec_info *); > -extern void free_stmt_vec_info (stmt_vec_info); > extern unsigned record_stmt_cost (stmt_vector_for_cost *, int, > enum vect_cost_for_stmt, stmt_vec_info, > int, enum vect_cost_model_location); > Index: gcc/tree-parloops.c > =================================================================== > --- gcc/tree-parloops.c 2018-07-24 10:22:57.273070426 +0100 > +++ gcc/tree-parloops.c 2018-07-24 10:24:29.296253164 +0100 > @@ -2592,10 +2592,6 @@ gather_scalar_reductions (loop_p loop, r > auto_vec double_reduc_phis; > auto_vec double_reduc_stmts; > > - vec stmt_vec_infos; > - stmt_vec_infos.create (50); > - set_stmt_vec_info_vec (&stmt_vec_infos); > - > vec_info_shared shared; > simple_loop_info = vect_analyze_loop_form (loop, &shared); > if (simple_loop_info == NULL) > @@ -2679,14 +2675,11 @@ gather_scalar_reductions (loop_p loop, r > } > > gather_done: > - /* Release the claim on gimple_uid. */ > - free_stmt_vec_infos (&stmt_vec_infos); > - > if (reduction_list->elements () == 0) > return; > > /* As gimple_uid is used by the vectorizer in between vect_analyze_loop_form > - and free_stmt_vec_info_vec, we can set gimple_uid of reduc_phi stmts only > + and delete simple_loop_info, we can set gimple_uid of reduc_phi stmts only > now. */ > basic_block bb; > FOR_EACH_BB_FN (bb, cfun) > Index: gcc/tree-vect-loop.c > =================================================================== > --- gcc/tree-vect-loop.c 2018-07-24 10:24:26.080281735 +0100 > +++ gcc/tree-vect-loop.c 2018-07-24 10:24:29.296253164 +0100 > @@ -888,8 +888,6 @@ _loop_vec_info::~_loop_vec_info () > gimple_stmt_iterator si; > int j; > > - /* ??? We're releasing loop_vinfos en-block. */ > - set_stmt_vec_info_vec (&stmt_vec_infos); > nbbs = loop->num_nodes; > for (j = 0; j < nbbs; j++) > { > Index: gcc/tree-vect-stmts.c > =================================================================== > --- gcc/tree-vect-stmts.c 2018-07-24 10:24:26.084281700 +0100 > +++ gcc/tree-vect-stmts.c 2018-07-24 10:24:29.300253129 +0100 > @@ -9850,98 +9850,6 @@ vect_remove_stores (stmt_vec_info first_ > } > } > > - > -/* Function new_stmt_vec_info. > - > - Create and initialize a new stmt_vec_info struct for STMT. */ > - > -stmt_vec_info > -new_stmt_vec_info (gimple *stmt, vec_info *vinfo) > -{ > - stmt_vec_info res; > - res = (_stmt_vec_info *) xcalloc (1, sizeof (struct _stmt_vec_info)); > - > - STMT_VINFO_TYPE (res) = undef_vec_info_type; > - STMT_VINFO_STMT (res) = stmt; > - res->vinfo = vinfo; > - STMT_VINFO_RELEVANT (res) = vect_unused_in_scope; > - STMT_VINFO_LIVE_P (res) = false; > - STMT_VINFO_VECTYPE (res) = NULL; > - STMT_VINFO_VEC_STMT (res) = NULL; > - STMT_VINFO_VECTORIZABLE (res) = true; > - STMT_VINFO_IN_PATTERN_P (res) = false; > - STMT_VINFO_PATTERN_DEF_SEQ (res) = NULL; > - STMT_VINFO_DATA_REF (res) = NULL; > - STMT_VINFO_VEC_REDUCTION_TYPE (res) = TREE_CODE_REDUCTION; > - STMT_VINFO_VEC_CONST_COND_REDUC_CODE (res) = ERROR_MARK; > - > - if (gimple_code (stmt) == GIMPLE_PHI > - && is_loop_header_bb_p (gimple_bb (stmt))) > - STMT_VINFO_DEF_TYPE (res) = vect_unknown_def_type; > - else > - STMT_VINFO_DEF_TYPE (res) = vect_internal_def; > - > - STMT_VINFO_SAME_ALIGN_REFS (res).create (0); > - STMT_SLP_TYPE (res) = loop_vect; > - STMT_VINFO_NUM_SLP_USES (res) = 0; > - > - res->first_element = NULL; /* GROUP_FIRST_ELEMENT */ > - res->next_element = NULL; /* GROUP_NEXT_ELEMENT */ > - res->size = 0; /* GROUP_SIZE */ > - res->store_count = 0; /* GROUP_STORE_COUNT */ > - res->gap = 0; /* GROUP_GAP */ > - res->same_dr_stmt = NULL; /* GROUP_SAME_DR_STMT */ > - > - /* This is really "uninitialized" until vect_compute_data_ref_alignment. */ > - res->dr_aux.misalignment = DR_MISALIGNMENT_UNINITIALIZED; > - > - return res; > -} > - > - > -/* Set the current stmt_vec_info vector to V. */ > - > -void > -set_stmt_vec_info_vec (vec *v) > -{ > - stmt_vec_info_vec = v; > -} > - > -/* Free the stmt_vec_info entries in V and release V. */ > - > -void > -free_stmt_vec_infos (vec *v) > -{ > - unsigned int i; > - stmt_vec_info info; > - FOR_EACH_VEC_ELT (*v, i, info) > - if (info != NULL_STMT_VEC_INFO) > - free_stmt_vec_info (info); > - if (v == stmt_vec_info_vec) > - stmt_vec_info_vec = NULL; > - v->release (); > -} > - > - > -/* Free stmt vectorization related info. */ > - > -void > -free_stmt_vec_info (stmt_vec_info stmt_info) > -{ > - if (stmt_info->pattern_stmt_p) > - { > - gimple_set_bb (stmt_info->stmt, NULL); > - tree lhs = gimple_get_lhs (stmt_info->stmt); > - if (lhs && TREE_CODE (lhs) == SSA_NAME) > - release_ssa_name (lhs); > - } > - > - STMT_VINFO_SAME_ALIGN_REFS (stmt_info).release (); > - STMT_VINFO_SIMD_CLONE_INFO (stmt_info).release (); > - free (stmt_info); > -} > - > - > /* Function get_vectype_for_scalar_type_and_size. > > Returns the vector type corresponding to SCALAR_TYPE and SIZE as supported > Index: gcc/tree-vectorizer.c > =================================================================== > --- gcc/tree-vectorizer.c 2018-07-24 10:24:26.084281700 +0100 > +++ gcc/tree-vectorizer.c 2018-07-24 10:24:29.300253129 +0100 > @@ -84,9 +84,6 @@ Software Foundation; either version 3, o > /* Loop or bb location, with hotness information. */ > dump_user_location_t vect_location; > > -/* Vector mapping GIMPLE stmt to stmt_vec_info. */ > -vec *stmt_vec_info_vec; > - > /* Dump a cost entry according to args to F. */ > > void > @@ -457,7 +454,6 @@ vec_info::vec_info (vec_info::vec_kind k > target_cost_data (target_cost_data_in) > { > stmt_vec_infos.create (50); > - set_stmt_vec_info_vec (&stmt_vec_infos); > } > > vec_info::~vec_info () > @@ -469,7 +465,7 @@ vec_info::~vec_info () > vect_free_slp_instance (instance, true); > > destroy_cost_data (target_cost_data); > - free_stmt_vec_infos (&stmt_vec_infos); > + free_stmt_vec_infos (); > } > > vec_info_shared::vec_info_shared () > @@ -513,7 +509,7 @@ vec_info_shared::check_datarefs () > stmt_vec_info > vec_info::add_stmt (gimple *stmt) > { > - stmt_vec_info res = new_stmt_vec_info (stmt, this); > + stmt_vec_info res = new_stmt_vec_info (stmt); > set_vinfo_for_stmt (stmt, res); > return res; > } > @@ -608,6 +604,87 @@ vec_info::replace_stmt (gimple_stmt_iter > gsi_replace (gsi, new_stmt, true); > } > > +/* Create and initialize a new stmt_vec_info struct for STMT. */ > + > +stmt_vec_info > +vec_info::new_stmt_vec_info (gimple *stmt) > +{ > + stmt_vec_info res = XCNEW (struct _stmt_vec_info); > + res->vinfo = this; > + res->stmt = stmt; > + > + STMT_VINFO_TYPE (res) = undef_vec_info_type; > + STMT_VINFO_RELEVANT (res) = vect_unused_in_scope; > + STMT_VINFO_VECTORIZABLE (res) = true; > + STMT_VINFO_VEC_REDUCTION_TYPE (res) = TREE_CODE_REDUCTION; > + STMT_VINFO_VEC_CONST_COND_REDUC_CODE (res) = ERROR_MARK; > + > + if (gimple_code (stmt) == GIMPLE_PHI > + && is_loop_header_bb_p (gimple_bb (stmt))) > + STMT_VINFO_DEF_TYPE (res) = vect_unknown_def_type; > + else > + STMT_VINFO_DEF_TYPE (res) = vect_internal_def; > + > + STMT_VINFO_SAME_ALIGN_REFS (res).create (0); > + STMT_SLP_TYPE (res) = loop_vect; > + > + /* This is really "uninitialized" until vect_compute_data_ref_alignment. */ > + res->dr_aux.misalignment = DR_MISALIGNMENT_UNINITIALIZED; > + > + return res; > +} > + > +/* Associate STMT with INFO. */ > + > +void > +vec_info::set_vinfo_for_stmt (gimple *stmt, stmt_vec_info info) > +{ > + unsigned int uid = gimple_uid (stmt); > + if (uid == 0) > + { > + gcc_checking_assert (info); > + uid = stmt_vec_infos.length () + 1; > + gimple_set_uid (stmt, uid); > + stmt_vec_infos.safe_push (info); > + } > + else > + { > + gcc_checking_assert (info == NULL_STMT_VEC_INFO); > + stmt_vec_infos[uid - 1] = info; > + } > +} > + > +/* Free the contents of stmt_vec_infos. */ > + > +void > +vec_info::free_stmt_vec_infos (void) > +{ > + unsigned int i; > + stmt_vec_info info; > + FOR_EACH_VEC_ELT (stmt_vec_infos, i, info) > + if (info != NULL_STMT_VEC_INFO) > + free_stmt_vec_info (info); > + stmt_vec_infos.release (); > +} > + > +/* Free STMT_INFO. */ > + > +void > +vec_info::free_stmt_vec_info (stmt_vec_info stmt_info) > +{ > + if (stmt_info->pattern_stmt_p) > + { > + gimple_set_bb (stmt_info->stmt, NULL); > + tree lhs = gimple_get_lhs (stmt_info->stmt); > + if (lhs && TREE_CODE (lhs) == SSA_NAME) > + release_ssa_name (lhs); > + } > + > + STMT_VINFO_SAME_ALIGN_REFS (stmt_info).release (); > + STMT_VINFO_SIMD_CLONE_INFO (stmt_info).release (); > + free (stmt_info); > +} > + > /* A helper function to free scev and LOOP niter information, as well as > clear loop constraint LOOP_C_FINITE. */ > > @@ -963,8 +1040,6 @@ vectorize_loops (void) > if (cfun->has_simduid_loops) > note_simd_array_uses (&simd_array_to_simduid_htab); > > - set_stmt_vec_info_vec (NULL); > - > /* ----------- Analyze loops. ----------- */ > > /* If some loop was duplicated, it gets bigger number