From patchwork Tue Jul 24 10:10:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 948329 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-482156-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="QBnxcrJD"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZYyM22DYz9ryt for ; Tue, 24 Jul 2018 20:10:19 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=default; b=N36i0XDiSlaV3HLqH4jiFD0Z47eHg qiL10pcZ+8aXeizwwFopschAFWchdyhcHEQht6sIPlh02MYaQ7U4fmtWmdze/3T7 yLehCJrFe2zDFBWm4f3KCuLx3bbbnuIk1INpggDSjmFXdwM3b1fMUqlSZFEcWYx+ oi0QB1KbuqqIEQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:references:date:in-reply-to:message-id:mime-version :content-type; s=default; bh=J/adLdocRWLU/ZdqUH6gy7Ji9oc=; b=QBn xcrJDxZ/kDqA68qMgtgEgjnuVLAi5xtbO/HNbD+Vm/PkJQv1EmXl8xqH0dDAycdG XS5OJS4NCAffwZHxgmIOzLlqGC+tvybHCIMSwahGm5+Y3yiumGvMejgqbGIX2Spv pz3+N66pVRMK9HADTjddxT9wFquI0KcH0Zw9o+1A= Received: (qmail 13515 invoked by alias); 24 Jul 2018 10:10:12 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 13496 invoked by uid 89); 24 Jul 2018 10:10:11 -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:10:10 +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 C73EC7A9 for ; Tue, 24 Jul 2018 03:10:08 -0700 (PDT) Received: from localhost (unknown [10.32.99.48]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 501FB3F237 for ; Tue, 24 Jul 2018 03:10:08 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [43/46] Make free_stmt_vec_info take a stmt_vec_info References: <87wotlrmen.fsf@arm.com> Date: Tue, 24 Jul 2018 11:10:06 +0100 In-Reply-To: <87wotlrmen.fsf@arm.com> (Richard Sandiford's message of "Tue, 24 Jul 2018 10:52:16 +0100") Message-ID: <87r2jtkkqp.fsf@arm.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 This patch makes free_stmt_vec_info take the stmt_vec_info that it's supposed to free and makes it free only that stmt_vec_info. Callers need to update the statement mapping where necessary (but now there are only a couple of callers). This in turns means that we can leave ~vec_info to do the actual freeing, since there's no longer a need to do it before resetting the gimple_uids. 2018-07-24 Richard Sandiford gcc/ * tree-vectorizer.h (free_stmt_vec_info): Take a stmt_vec_info rather than a gimple stmt. * tree-vect-stmts.c (free_stmt_vec_info): Likewise. Don't free information for pattern statements when passed the original statement; instead wait to be passed the pattern statement itself. Don't call set_vinfo_for_stmt here. (free_stmt_vec_infos): Update call to free_stmt_vec_info. * tree-vect-loop.c (_loop_vec_info::~loop_vec_info): Don't free stmt_vec_infos here. * tree-vect-slp.c (_bb_vec_info::~bb_vec_info): Likewise. * tree-vectorizer.c (vec_info::remove_stmt): Nullify the statement's stmt_vec_infos entry. Index: gcc/tree-vectorizer.h =================================================================== --- gcc/tree-vectorizer.h 2018-07-24 10:24:22.684311906 +0100 +++ gcc/tree-vectorizer.h 2018-07-24 10:24:26.084281700 +0100 @@ -1484,7 +1484,7 @@ extern bool supportable_narrowing_operat enum tree_code *, int *, vec *); extern stmt_vec_info new_stmt_vec_info (gimple *stmt, vec_info *); -extern void free_stmt_vec_info (gimple *stmt); +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-vect-stmts.c =================================================================== --- gcc/tree-vect-stmts.c 2018-07-24 10:24:22.684311906 +0100 +++ gcc/tree-vect-stmts.c 2018-07-24 10:24:26.084281700 +0100 @@ -9916,7 +9916,7 @@ free_stmt_vec_infos (vec stmt_vec_info info; FOR_EACH_VEC_ELT (*v, i, info) if (info != NULL_STMT_VEC_INFO) - free_stmt_vec_info (STMT_VINFO_STMT (info)); + free_stmt_vec_info (info); if (v == stmt_vec_info_vec) stmt_vec_info_vec = NULL; v->release (); @@ -9926,44 +9926,18 @@ free_stmt_vec_infos (vec /* Free stmt vectorization related info. */ void -free_stmt_vec_info (gimple *stmt) +free_stmt_vec_info (stmt_vec_info stmt_info) { - stmt_vec_info stmt_info = vinfo_for_stmt (stmt); - - if (!stmt_info) - return; - - /* Check if this statement has a related "pattern stmt" - (introduced by the vectorizer during the pattern recognition - pass). Free pattern's stmt_vec_info and def stmt's stmt_vec_info - too. */ - if (STMT_VINFO_IN_PATTERN_P (stmt_info)) + if (stmt_info->pattern_stmt_p) { - if (gimple_seq seq = STMT_VINFO_PATTERN_DEF_SEQ (stmt_info)) - for (gimple_stmt_iterator si = gsi_start (seq); - !gsi_end_p (si); gsi_next (&si)) - { - gimple *seq_stmt = gsi_stmt (si); - gimple_set_bb (seq_stmt, NULL); - tree lhs = gimple_get_lhs (seq_stmt); - if (lhs && TREE_CODE (lhs) == SSA_NAME) - release_ssa_name (lhs); - free_stmt_vec_info (seq_stmt); - } - stmt_vec_info patt_stmt_info = STMT_VINFO_RELATED_STMT (stmt_info); - if (patt_stmt_info) - { - gimple_set_bb (patt_stmt_info->stmt, NULL); - tree lhs = gimple_get_lhs (patt_stmt_info->stmt); - if (lhs && TREE_CODE (lhs) == SSA_NAME) - release_ssa_name (lhs); - free_stmt_vec_info (patt_stmt_info); - } + 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 (); - set_vinfo_for_stmt (stmt, NULL); free (stmt_info); } Index: gcc/tree-vect-loop.c =================================================================== --- gcc/tree-vect-loop.c 2018-07-24 10:24:19.540339838 +0100 +++ gcc/tree-vect-loop.c 2018-07-24 10:24:26.080281735 +0100 @@ -894,9 +894,6 @@ _loop_vec_info::~_loop_vec_info () for (j = 0; j < nbbs; j++) { basic_block bb = bbs[j]; - for (si = gsi_start_phis (bb); !gsi_end_p (si); gsi_next (&si)) - free_stmt_vec_info (gsi_stmt (si)); - for (si = gsi_start_bb (bb); !gsi_end_p (si); ) { gimple *stmt = gsi_stmt (si); @@ -936,9 +933,6 @@ _loop_vec_info::~_loop_vec_info () } } } - - /* Free stmt_vec_info. */ - free_stmt_vec_info (stmt); gsi_next (&si); } } Index: gcc/tree-vect-slp.c =================================================================== --- gcc/tree-vect-slp.c 2018-07-24 10:24:22.680311942 +0100 +++ gcc/tree-vect-slp.c 2018-07-24 10:24:26.080281735 +0100 @@ -2490,17 +2490,8 @@ _bb_vec_info::~_bb_vec_info () { for (gimple_stmt_iterator si = region_begin; gsi_stmt (si) != gsi_stmt (region_end); gsi_next (&si)) - { - gimple *stmt = gsi_stmt (si); - stmt_vec_info stmt_info = vinfo_for_stmt (stmt); - - if (stmt_info) - /* Free stmt_vec_info. */ - free_stmt_vec_info (stmt); - - /* Reset region marker. */ - gimple_set_uid (stmt, -1); - } + /* Reset region marker. */ + gimple_set_uid (gsi_stmt (si), -1); bb->aux = NULL; } Index: gcc/tree-vectorizer.c =================================================================== --- gcc/tree-vectorizer.c 2018-07-24 10:24:22.684311906 +0100 +++ gcc/tree-vectorizer.c 2018-07-24 10:24:26.084281700 +0100 @@ -584,6 +584,7 @@ vec_info::lookup_dr (data_reference *dr) vec_info::remove_stmt (stmt_vec_info stmt_info) { gcc_assert (!stmt_info->pattern_stmt_p); + set_vinfo_for_stmt (stmt_info->stmt, NULL); gimple_stmt_iterator si = gsi_for_stmt (stmt_info->stmt); unlink_stmt_vdef (stmt_info->stmt); gsi_remove (&si, true);