From patchwork Tue Jul 24 10:04:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 948315 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-482141-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="VPdUi6jZ"; 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 41ZYr56mFWz9ryt for ; Tue, 24 Jul 2018 20:04:53 +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=R0erBzXIkr8cNURcpFDtLmp++JVex PoVIDlqYVWojPGYJ/EV0rHSlsp/QGArzSlgcwzAqn3XbYnYM6XYmloqRwjQXcu4j PQcoLOYxU2yR0hfyj7trS8tKaK22U2Dj5lNzW+ElRjyKc9JBSKM6ne3mo6lKdxk6 AF0hWhACh4AiW4= 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=Xg0TvqTDFKlB9ziCgv9AiPKXruE=; b=VPd Ui6jZWchgE9V6BMFgJ3x+oYDEawgNjiS5J0Ai0ZSDEHCzLzA1w+cURTdFzANUea9 hhJAoAxZpwEISFJaiasA8tEA581lI9LzpmhDLYCHDjSreuhspl1jHsMrqZ9pYHeq ZVRPS2htqodtCe2KUHeFf/JVGtq/uy/iYUvsXK3c= Received: (qmail 83119 invoked by alias); 24 Jul 2018 10:04:37 -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 83024 invoked by uid 89); 24 Jul 2018 10:04:36 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-16.1 required=5.0 tests=BAYES_00, GIT_PATCH_1, 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:04:32 +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 B290A80D for ; Tue, 24 Jul 2018 03:04:30 -0700 (PDT) Received: from localhost (unknown [10.32.99.48]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3AC593F237 for ; Tue, 24 Jul 2018 03:04:30 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [29/46] Use stmt_vec_info instead of gimple stmts internally (part 2) References: <87wotlrmen.fsf@arm.com> Date: Tue, 24 Jul 2018 11:04:28 +0100 In-Reply-To: <87wotlrmen.fsf@arm.com> (Richard Sandiford's message of "Tue, 24 Jul 2018 10:52:16 +0100") Message-ID: <87fu09ne4z.fsf@arm.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 This second part handles the less mechnical cases, i.e. those that don't just involve swapping a gimple stmt for an existing stmt_vec_info. 2018-07-24 Richard Sandiford gcc/ * tree-vect-loop.c (vect_analyze_loop_operations): Look up the statement before passing it to vect_analyze_stmt. (vect_create_epilog_for_reduction): Use a stmt_vec_info to walk the chain of phi vector definitions. Track the exit phi via its stmt_vec_info. (vectorizable_reduction): Set cond_stmt_vinfo directly from the STMT_VINFO_REDUC_DEF. * tree-vect-slp.c (vect_get_place_in_interleaving_chain): Use stmt_vec_infos to handle the statement chains. (vect_get_slp_defs): Record the first statement in the node using a stmt_vec_info. * tree-vect-stmts.c (vect_mark_stmts_to_be_vectorized): Look up statements here and pass their stmt_vec_info down to subroutines. (vect_init_vector_1): Hoist call to vinfo_for_stmt and pass it down to vect_finish_stmt_generation. (vect_init_vector, vect_get_vec_defs, vect_finish_replace_stmt) (vect_finish_stmt_generation): Call vinfo_for_stmt and pass stmt_vec_infos to subroutines. (vect_remove_stores): Use stmt_vec_infos to handle the statement chains. Index: gcc/tree-vect-loop.c =================================================================== --- gcc/tree-vect-loop.c 2018-07-24 10:23:35.376732054 +0100 +++ gcc/tree-vect-loop.c 2018-07-24 10:23:38.964700191 +0100 @@ -1629,8 +1629,9 @@ vect_analyze_loop_operations (loop_vec_i { gimple *stmt = gsi_stmt (si); if (!gimple_clobber_p (stmt) - && !vect_analyze_stmt (stmt, &need_to_vectorize, NULL, NULL, - &cost_vec)) + && !vect_analyze_stmt (loop_vinfo->lookup_stmt (stmt), + &need_to_vectorize, + NULL, NULL, &cost_vec)) return false; } } /* bbs */ @@ -4832,11 +4833,11 @@ vect_create_epilog_for_reduction (veclookup_stmt (new_phis[0]); for (int k = 1; k < ncopies; ++k) { - next_phi = STMT_VINFO_RELATED_STMT (vinfo_for_stmt (next_phi)); - tree second_vect = PHI_RESULT (next_phi); + next_phi_info = STMT_VINFO_RELATED_STMT (next_phi_info); + tree second_vect = PHI_RESULT (next_phi_info->stmt); tree tem = make_ssa_name (vec_dest, new_vec_stmt); new_vec_stmt = gimple_build_assign (tem, code, first_vect, second_vect); @@ -5573,11 +5574,12 @@ vect_create_epilog_for_reduction (veclookup_stmt (new_phis[k / ratio]); reduction_phi_info = reduction_phis[k / ratio]; if (double_reduc) inner_phi = inner_phis[k / ratio]; @@ -5623,8 +5625,7 @@ vect_create_epilog_for_reduction (vec ops, slp_tree slp_node, vec > *vec_oprnds) { - gimple *first_stmt; int number_of_vects = 0, i; unsigned int child_index = 0; HOST_WIDE_INT lhs_size_unit, rhs_size_unit; @@ -3586,7 +3587,7 @@ vect_get_slp_defs (vec ops, slp_tr tree oprnd; bool vectorized_defs; - first_stmt = SLP_TREE_SCALAR_STMTS (slp_node)[0]; + stmt_vec_info first_stmt_info = SLP_TREE_SCALAR_STMTS (slp_node)[0]; FOR_EACH_VEC_ELT (ops, i, oprnd) { /* For each operand we check if it has vectorized definitions in a child @@ -3637,8 +3638,8 @@ vect_get_slp_defs (vec ops, slp_tr vect_schedule_slp_instance (), fix it by replacing LHS with RHS, if necessary. See vect_get_smallest_scalar_type () for details. */ - vect_get_smallest_scalar_type (first_stmt, &lhs_size_unit, - &rhs_size_unit); + vect_get_smallest_scalar_type (first_stmt_info, &lhs_size_unit, + &rhs_size_unit); if (rhs_size_unit != lhs_size_unit) { number_of_vects *= rhs_size_unit; Index: gcc/tree-vect-stmts.c =================================================================== --- gcc/tree-vect-stmts.c 2018-07-24 10:23:35.384731983 +0100 +++ gcc/tree-vect-stmts.c 2018-07-24 10:23:38.968700155 +0100 @@ -622,7 +622,6 @@ vect_mark_stmts_to_be_vectorized (loop_v unsigned int i; stmt_vec_info stmt_vinfo; basic_block bb; - gimple *phi; bool live_p; enum vect_relevant relevant; @@ -636,27 +635,27 @@ vect_mark_stmts_to_be_vectorized (loop_v bb = bbs[i]; for (si = gsi_start_phis (bb); !gsi_end_p (si); gsi_next (&si)) { - phi = gsi_stmt (si); + stmt_vec_info phi_info = loop_vinfo->lookup_stmt (gsi_stmt (si)); if (dump_enabled_p ()) { dump_printf_loc (MSG_NOTE, vect_location, "init: phi relevant? "); - dump_gimple_stmt (MSG_NOTE, TDF_SLIM, phi, 0); + dump_gimple_stmt (MSG_NOTE, TDF_SLIM, phi_info->stmt, 0); } - if (vect_stmt_relevant_p (phi, loop_vinfo, &relevant, &live_p)) - vect_mark_relevant (&worklist, phi, relevant, live_p); + if (vect_stmt_relevant_p (phi_info, loop_vinfo, &relevant, &live_p)) + vect_mark_relevant (&worklist, phi_info, relevant, live_p); } for (si = gsi_start_bb (bb); !gsi_end_p (si); gsi_next (&si)) { - stmt = gsi_stmt (si); + stmt_vec_info stmt_info = loop_vinfo->lookup_stmt (gsi_stmt (si)); if (dump_enabled_p ()) { dump_printf_loc (MSG_NOTE, vect_location, "init: stmt relevant? "); - dump_gimple_stmt (MSG_NOTE, TDF_SLIM, stmt, 0); + dump_gimple_stmt (MSG_NOTE, TDF_SLIM, stmt_info->stmt, 0); } - if (vect_stmt_relevant_p (stmt, loop_vinfo, &relevant, &live_p)) - vect_mark_relevant (&worklist, stmt, relevant, live_p); + if (vect_stmt_relevant_p (stmt_info, loop_vinfo, &relevant, &live_p)) + vect_mark_relevant (&worklist, stmt_info, relevant, live_p); } } @@ -1350,11 +1349,11 @@ vect_get_load_cost (stmt_vec_info stmt_i static void vect_init_vector_1 (gimple *stmt, gimple *new_stmt, gimple_stmt_iterator *gsi) { + stmt_vec_info stmt_vinfo = vinfo_for_stmt (stmt); if (gsi) - vect_finish_stmt_generation (stmt, new_stmt, gsi); + vect_finish_stmt_generation (stmt_vinfo, new_stmt, gsi); else { - stmt_vec_info stmt_vinfo = vinfo_for_stmt (stmt); loop_vec_info loop_vinfo = STMT_VINFO_LOOP_VINFO (stmt_vinfo); if (loop_vinfo) @@ -1404,6 +1403,7 @@ vect_init_vector_1 (gimple *stmt, gimple tree vect_init_vector (gimple *stmt, tree val, tree type, gimple_stmt_iterator *gsi) { + stmt_vec_info stmt_info = vinfo_for_stmt (stmt); gimple *init_stmt; tree new_temp; @@ -1427,7 +1427,7 @@ vect_init_vector (gimple *stmt, tree val new_temp = make_ssa_name (TREE_TYPE (type)); init_stmt = gimple_build_assign (new_temp, COND_EXPR, val, true_val, false_val); - vect_init_vector_1 (stmt, init_stmt, gsi); + vect_init_vector_1 (stmt_info, init_stmt, gsi); val = new_temp; } } @@ -1443,7 +1443,7 @@ vect_init_vector (gimple *stmt, tree val val)); else init_stmt = gimple_build_assign (new_temp, NOP_EXPR, val); - vect_init_vector_1 (stmt, init_stmt, gsi); + vect_init_vector_1 (stmt_info, init_stmt, gsi); val = new_temp; } } @@ -1452,7 +1452,7 @@ vect_init_vector (gimple *stmt, tree val new_temp = vect_get_new_ssa_name (type, vect_simple_var, "cst_"); init_stmt = gimple_build_assign (new_temp, val); - vect_init_vector_1 (stmt, init_stmt, gsi); + vect_init_vector_1 (stmt_info, init_stmt, gsi); return new_temp; } @@ -1690,6 +1690,7 @@ vect_get_vec_defs (tree op0, tree op1, g vec *vec_oprnds1, slp_tree slp_node) { + stmt_vec_info stmt_info = vinfo_for_stmt (stmt); if (slp_node) { int nops = (op1 == NULL_TREE) ? 1 : 2; @@ -1711,13 +1712,13 @@ vect_get_vec_defs (tree op0, tree op1, g tree vec_oprnd; vec_oprnds0->create (1); - vec_oprnd = vect_get_vec_def_for_operand (op0, stmt); + vec_oprnd = vect_get_vec_def_for_operand (op0, stmt_info); vec_oprnds0->quick_push (vec_oprnd); if (op1) { vec_oprnds1->create (1); - vec_oprnd = vect_get_vec_def_for_operand (op1, stmt); + vec_oprnd = vect_get_vec_def_for_operand (op1, stmt_info); vec_oprnds1->quick_push (vec_oprnd); } } @@ -1760,12 +1761,13 @@ vect_finish_stmt_generation_1 (gimple *s stmt_vec_info vect_finish_replace_stmt (gimple *stmt, gimple *vec_stmt) { - gcc_assert (gimple_get_lhs (stmt) == gimple_get_lhs (vec_stmt)); + stmt_vec_info stmt_info = vinfo_for_stmt (stmt); + gcc_assert (gimple_get_lhs (stmt_info->stmt) == gimple_get_lhs (vec_stmt)); - gimple_stmt_iterator gsi = gsi_for_stmt (stmt); + gimple_stmt_iterator gsi = gsi_for_stmt (stmt_info->stmt); gsi_replace (&gsi, vec_stmt, false); - return vect_finish_stmt_generation_1 (stmt, vec_stmt); + return vect_finish_stmt_generation_1 (stmt_info, vec_stmt); } /* Add VEC_STMT to the vectorized implementation of STMT and insert it @@ -1775,7 +1777,8 @@ vect_finish_replace_stmt (gimple *stmt, vect_finish_stmt_generation (gimple *stmt, gimple *vec_stmt, gimple_stmt_iterator *gsi) { - gcc_assert (gimple_code (stmt) != GIMPLE_LABEL); + stmt_vec_info stmt_info = vinfo_for_stmt (stmt); + gcc_assert (gimple_code (stmt_info->stmt) != GIMPLE_LABEL); if (!gsi_end_p (*gsi) && gimple_has_mem_ops (vec_stmt)) @@ -1804,7 +1807,7 @@ vect_finish_stmt_generation (gimple *stm } } gsi_insert_before (gsi, vec_stmt, GSI_SAME_STMT); - return vect_finish_stmt_generation_1 (stmt, vec_stmt); + return vect_finish_stmt_generation_1 (stmt_info, vec_stmt); } /* We want to vectorize a call to combined function CFN with function @@ -9856,23 +9859,21 @@ vect_transform_stmt (gimple *stmt, gimpl void vect_remove_stores (gimple *first_stmt) { - gimple *next = first_stmt; + stmt_vec_info next_stmt_info = vinfo_for_stmt (first_stmt); gimple_stmt_iterator next_si; - while (next) + while (next_stmt_info) { - stmt_vec_info stmt_info = vinfo_for_stmt (next); - - stmt_vec_info tmp = DR_GROUP_NEXT_ELEMENT (stmt_info); - if (is_pattern_stmt_p (stmt_info)) - next = STMT_VINFO_RELATED_STMT (stmt_info); + stmt_vec_info tmp = DR_GROUP_NEXT_ELEMENT (next_stmt_info); + if (is_pattern_stmt_p (next_stmt_info)) + 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); - unlink_stmt_vdef (next); + next_si = gsi_for_stmt (next_stmt_info->stmt); + unlink_stmt_vdef (next_stmt_info->stmt); gsi_remove (&next_si, true); - release_defs (next); - free_stmt_vec_info (next); - next = tmp; + release_defs (next_stmt_info->stmt); + free_stmt_vec_info (next_stmt_info); + next_stmt_info = tmp; } }