From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10297 invoked by alias); 24 Jul 2018 10:09:26 -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 10260 invoked by uid 89); 24 Jul 2018 10:09:25 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00,GIT_PATCH_2,GIT_PATCH_3,KAM_ASCII_DIVIDERS,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 24 Jul 2018 10:09:23 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A53B07A9 for ; Tue, 24 Jul 2018 03:09:22 -0700 (PDT) Received: from localhost (unknown [10.32.99.48]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2E0E63F237 for ; Tue, 24 Jul 2018 03:09:22 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [41/46] Add vec_info::remove_stmt References: <87wotlrmen.fsf@arm.com> Date: Tue, 24 Jul 2018 10:09:00 -0000 In-Reply-To: <87wotlrmen.fsf@arm.com> (Richard Sandiford's message of "Tue, 24 Jul 2018 10:52:16 +0100") Message-ID: <87zhyhkkrz.fsf@arm.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2018-07/txt/msg01351.txt.bz2 This patch adds a new helper function for permanently removing a statement and its associated stmt_vec_info. 2018-07-24 Richard Sandiford gcc/ * tree-vectorizer.h (vec_info::remove_stmt): Declare. * tree-vectorizer.c (vec_info::remove_stmt): New function. * tree-vect-loop-manip.c (vect_set_loop_condition): Use it. * tree-vect-loop.c (vect_transform_loop): Likewise. * tree-vect-slp.c (vect_schedule_slp): Likewise. * tree-vect-stmts.c (vect_remove_stores): Likewise. Index: gcc/tree-vectorizer.h =================================================================== --- gcc/tree-vectorizer.h 2018-07-24 10:24:16.552366384 +0100 +++ gcc/tree-vectorizer.h 2018-07-24 10:24:19.544339803 +0100 @@ -241,6 +241,7 @@ struct vec_info { stmt_vec_info lookup_def (tree); stmt_vec_info lookup_single_use (tree); stmt_vec_info lookup_dr (data_reference *); + void remove_stmt (stmt_vec_info); /* The type of vectorization. */ vec_kind kind; Index: gcc/tree-vectorizer.c =================================================================== --- gcc/tree-vectorizer.c 2018-07-24 10:24:16.552366384 +0100 +++ gcc/tree-vectorizer.c 2018-07-24 10:24:19.544339803 +0100 @@ -577,6 +577,20 @@ vec_info::lookup_dr (data_reference *dr) return stmt_info; } +/* Permanently remove the statement described by STMT_INFO from the + function. */ + +void +vec_info::remove_stmt (stmt_vec_info stmt_info) +{ + gcc_assert (!stmt_info->pattern_stmt_p); + gimple_stmt_iterator si = gsi_for_stmt (stmt_info->stmt); + unlink_stmt_vdef (stmt_info->stmt); + gsi_remove (&si, true); + release_defs (stmt_info->stmt); + free_stmt_vec_info (stmt_info); +} + /* A helper function to free scev and LOOP niter information, as well as clear loop constraint LOOP_C_FINITE. */ Index: gcc/tree-vect-loop-manip.c =================================================================== --- gcc/tree-vect-loop-manip.c 2018-07-24 10:24:16.552366384 +0100 +++ gcc/tree-vect-loop-manip.c 2018-07-24 10:24:19.540339838 +0100 @@ -935,8 +935,12 @@ vect_set_loop_condition (struct loop *lo loop_cond_gsi); /* Remove old loop exit test. */ - gsi_remove (&loop_cond_gsi, true); - free_stmt_vec_info (orig_cond); + stmt_vec_info orig_cond_info; + if (loop_vinfo + && (orig_cond_info = loop_vinfo->lookup_stmt (orig_cond))) + loop_vinfo->remove_stmt (orig_cond_info); + else + gsi_remove (&loop_cond_gsi, true); if (dump_enabled_p ()) { Index: gcc/tree-vect-loop.c =================================================================== --- gcc/tree-vect-loop.c 2018-07-24 10:24:12.252404574 +0100 +++ gcc/tree-vect-loop.c 2018-07-24 10:24:19.540339838 +0100 @@ -8487,28 +8487,18 @@ vect_transform_loop (loop_vec_info loop_ vect_transform_loop_stmt (loop_vinfo, stmt_info, &si, &seen_store, &slp_scheduled); } + gsi_next (&si); if (seen_store) { if (STMT_VINFO_GROUPED_ACCESS (seen_store)) - { - /* Interleaving. If IS_STORE is TRUE, the - vectorization of the interleaving chain was - completed - free all the stores in the chain. */ - gsi_next (&si); - vect_remove_stores (DR_GROUP_FIRST_ELEMENT (seen_store)); - } + /* Interleaving. If IS_STORE is TRUE, the + vectorization of the interleaving chain was + completed - free all the stores in the chain. */ + vect_remove_stores (DR_GROUP_FIRST_ELEMENT (seen_store)); else - { - /* Free the attached stmt_vec_info and remove the - stmt. */ - free_stmt_vec_info (stmt); - unlink_stmt_vdef (stmt); - gsi_remove (&si, true); - release_defs (stmt); - } + /* Free the attached stmt_vec_info and remove the stmt. */ + loop_vinfo->remove_stmt (stmt_info); } - else - gsi_next (&si); } } Index: gcc/tree-vect-slp.c =================================================================== --- gcc/tree-vect-slp.c 2018-07-24 10:24:02.360492422 +0100 +++ gcc/tree-vect-slp.c 2018-07-24 10:24:19.540339838 +0100 @@ -4087,7 +4087,6 @@ vect_schedule_slp (vec_info *vinfo) slp_tree root = SLP_INSTANCE_TREE (instance); stmt_vec_info store_info; unsigned int j; - gimple_stmt_iterator gsi; /* Remove scalar call stmts. Do not do this for basic-block vectorization as not all uses may be vectorized. @@ -4108,11 +4107,7 @@ vect_schedule_slp (vec_info *vinfo) if (store_info->pattern_stmt_p) store_info = STMT_VINFO_RELATED_STMT (store_info); /* Free the attached stmt_vec_info and remove the stmt. */ - gsi = gsi_for_stmt (store_info); - unlink_stmt_vdef (store_info); - gsi_remove (&gsi, true); - release_defs (store_info); - free_stmt_vec_info (store_info); + vinfo->remove_stmt (store_info); } } Index: gcc/tree-vect-stmts.c =================================================================== --- gcc/tree-vect-stmts.c 2018-07-24 10:24:08.924434128 +0100 +++ gcc/tree-vect-stmts.c 2018-07-24 10:24:19.544339803 +0100 @@ -9842,8 +9842,8 @@ vect_transform_stmt (stmt_vec_info stmt_ void vect_remove_stores (stmt_vec_info first_stmt_info) { + vec_info *vinfo = first_stmt_info->vinfo; stmt_vec_info next_stmt_info = first_stmt_info; - gimple_stmt_iterator next_si; while (next_stmt_info) { @@ -9851,11 +9851,7 @@ vect_remove_stores (stmt_vec_info first_ if (next_stmt_info->pattern_stmt_p) next_stmt_info = STMT_VINFO_RELATED_STMT (next_stmt_info); /* Free the attached stmt_vec_info and remove the stmt. */ - next_si = gsi_for_stmt (next_stmt_info->stmt); - unlink_stmt_vdef (next_stmt_info->stmt); - gsi_remove (&next_si, true); - release_defs (next_stmt_info->stmt); - free_stmt_vec_info (next_stmt_info); + vinfo->remove_stmt (next_stmt_info); next_stmt_info = tmp; } }