From patchwork Tue Jul 24 09:58:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 948298 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-482124-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="lbt7C12Y"; 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 41ZYhq13sTz9ryt for ; Tue, 24 Jul 2018 19:58:34 +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=NH2cwAEvQvOc5z4uVhlhZt0+88Gzt dZ0Pup9WxgLhX5dGtsBvIxk1KGl1RuaTz6+q1I7dC9/e2XZy6Kk+G7KH43IvB510 xZHi9IQgVVk0Jt1aCJFaF07Geg+eMjNW3/sBwoWwWdth190jcKSnOxWd+dflSIHd xqOJnCTROOXj1k= 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=/5RJh10U4wQiv9Ji1OFItgyVY1o=; b=lbt 7C12YTB3R3EK5L8Edx+UepoMhQ7OYq9XgwDxy6llvv1wUrt/5YYqivv0O4Sh6wQh 8skKTinvurmJXhq8GyuMZst7DV0Po3Hu3s643doLlv4YGYVOnv3gBC0x9JNrDDiC DSF+/K4hS+n1hiMxykAedfXkUUn3Ps/OeUi4QLbA= Received: (qmail 19217 invoked by alias); 24 Jul 2018 09:58:25 -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 19206 invoked by uid 89); 24 Jul 2018 09:58: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 09:58:20 +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 D8A827A9 for ; Tue, 24 Jul 2018 02:58:18 -0700 (PDT) Received: from localhost (unknown [10.32.99.48]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3CF0A3F237 for ; Tue, 24 Jul 2018 02:58:18 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [13/46] Make STMT_VINFO_RELATED_STMT a stmt_vec_info References: <87wotlrmen.fsf@arm.com> Date: Tue, 24 Jul 2018 10:58:16 +0100 In-Reply-To: <87wotlrmen.fsf@arm.com> (Richard Sandiford's message of "Tue, 24 Jul 2018 10:52:16 +0100") Message-ID: <87d0vdq7k7.fsf@arm.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 This patch changes STMT_VINFO_RELATED_STMT from a gimple stmt to a stmt_vec_info. 2018-07-24 Richard Sandiford gcc/ * tree-vectorizer.h (_stmt_vec_info::related_stmt): Change from a gimple stmt to a stmt_vec_info. (is_pattern_stmt_p): Update accordingly. * tree-vect-data-refs.c (vect_preserves_scalar_order_p): Likewise. (vect_record_grouped_load_vectors): Likewise. * tree-vect-loop.c (vect_determine_vf_for_stmt): Likewise. (vect_fixup_reduc_chain, vect_update_vf_for_slp): Likewise. (vect_model_reduction_cost): Likewise. (vect_create_epilog_for_reduction): Likewise. (vectorizable_reduction, vectorizable_induction): Likewise. * tree-vect-patterns.c (vect_init_pattern_stmt): Likewise. Return the stmt_vec_info for the pattern statement. (vect_set_pattern_stmt): Update use of STMT_VINFO_RELATED_STMT. (vect_split_statement, vect_mark_pattern_stmts): Likewise. * tree-vect-slp.c (vect_detect_hybrid_slp_stmts): Likewise. (vect_detect_hybrid_slp, vect_get_slp_defs): Likewise. * tree-vect-stmts.c (vect_mark_relevant): Likewise. (vect_get_vec_def_for_operand_1, vectorizable_call): Likewise. (vectorizable_simd_clone_call, vect_analyze_stmt, new_stmt_vec_info) (free_stmt_vec_info, vect_is_simple_use): Likewise. Index: gcc/tree-vectorizer.h =================================================================== --- gcc/tree-vectorizer.h 2018-07-24 10:22:40.725217371 +0100 +++ gcc/tree-vectorizer.h 2018-07-24 10:22:44.297185652 +0100 @@ -847,7 +847,7 @@ struct _stmt_vec_info { related_stmt of the "pattern stmt" points back to this stmt (which is the last stmt in the original sequence of stmts that constitutes the pattern). */ - gimple *related_stmt; + stmt_vec_info related_stmt; /* Used to keep a sequence of def stmts of a pattern stmt if such exists. The sequence is attached to the original statement rather than the @@ -1189,16 +1189,8 @@ get_later_stmt (gimple *stmt1, gimple *s static inline bool is_pattern_stmt_p (stmt_vec_info stmt_info) { - gimple *related_stmt; - stmt_vec_info related_stmt_info; - - related_stmt = STMT_VINFO_RELATED_STMT (stmt_info); - if (related_stmt - && (related_stmt_info = vinfo_for_stmt (related_stmt)) - && STMT_VINFO_IN_PATTERN_P (related_stmt_info)) - return true; - - return false; + stmt_vec_info related_stmt_info = STMT_VINFO_RELATED_STMT (stmt_info); + return related_stmt_info && STMT_VINFO_IN_PATTERN_P (related_stmt_info); } /* Return true if BB is a loop header. */ Index: gcc/tree-vect-data-refs.c =================================================================== --- gcc/tree-vect-data-refs.c 2018-07-24 10:22:19.801403171 +0100 +++ gcc/tree-vect-data-refs.c 2018-07-24 10:22:44.285185759 +0100 @@ -213,10 +213,10 @@ vect_preserves_scalar_order_p (gimple *s current position (but could happen earlier). Reordering is therefore only possible if the first access is a write. */ if (is_pattern_stmt_p (stmtinfo_a)) - stmt_a = STMT_VINFO_RELATED_STMT (stmtinfo_a); + stmtinfo_a = STMT_VINFO_RELATED_STMT (stmtinfo_a); if (is_pattern_stmt_p (stmtinfo_b)) - stmt_b = STMT_VINFO_RELATED_STMT (stmtinfo_b); - gimple *earlier_stmt = get_earlier_stmt (stmt_a, stmt_b); + stmtinfo_b = STMT_VINFO_RELATED_STMT (stmtinfo_b); + gimple *earlier_stmt = get_earlier_stmt (stmtinfo_a, stmtinfo_b); return !DR_IS_WRITE (STMT_VINFO_DATA_REF (vinfo_for_stmt (earlier_stmt))); } @@ -6359,8 +6359,10 @@ vect_transform_grouped_load (gimple *stm void vect_record_grouped_load_vectors (gimple *stmt, vec result_chain) { - gimple *first_stmt = DR_GROUP_FIRST_ELEMENT (vinfo_for_stmt (stmt)); - gimple *next_stmt, *new_stmt; + stmt_vec_info stmt_info = vinfo_for_stmt (stmt); + vec_info *vinfo = stmt_info->vinfo; + gimple *first_stmt = DR_GROUP_FIRST_ELEMENT (stmt_info); + gimple *next_stmt; unsigned int i, gap_count; tree tmp_data_ref; @@ -6389,29 +6391,28 @@ vect_record_grouped_load_vectors (gimple while (next_stmt) { - new_stmt = SSA_NAME_DEF_STMT (tmp_data_ref); + stmt_vec_info new_stmt_info = vinfo->lookup_def (tmp_data_ref); /* We assume that if VEC_STMT is not NULL, this is a case of multiple copies, and we put the new vector statement in the first available RELATED_STMT. */ if (!STMT_VINFO_VEC_STMT (vinfo_for_stmt (next_stmt))) - STMT_VINFO_VEC_STMT (vinfo_for_stmt (next_stmt)) = new_stmt; + STMT_VINFO_VEC_STMT (vinfo_for_stmt (next_stmt)) = new_stmt_info; else { if (!DR_GROUP_SAME_DR_STMT (vinfo_for_stmt (next_stmt))) { gimple *prev_stmt = STMT_VINFO_VEC_STMT (vinfo_for_stmt (next_stmt)); - gimple *rel_stmt = - STMT_VINFO_RELATED_STMT (vinfo_for_stmt (prev_stmt)); - while (rel_stmt) + stmt_vec_info rel_stmt_info + = STMT_VINFO_RELATED_STMT (vinfo_for_stmt (prev_stmt)); + while (rel_stmt_info) { - prev_stmt = rel_stmt; - rel_stmt = - STMT_VINFO_RELATED_STMT (vinfo_for_stmt (rel_stmt)); + prev_stmt = rel_stmt_info; + rel_stmt_info = STMT_VINFO_RELATED_STMT (rel_stmt_info); } - STMT_VINFO_RELATED_STMT (vinfo_for_stmt (prev_stmt)) = - new_stmt; + STMT_VINFO_RELATED_STMT (vinfo_for_stmt (prev_stmt)) + = new_stmt_info; } } Index: gcc/tree-vect-loop.c =================================================================== --- gcc/tree-vect-loop.c 2018-07-24 10:22:40.721217407 +0100 +++ gcc/tree-vect-loop.c 2018-07-24 10:22:44.289185723 +0100 @@ -226,7 +226,7 @@ vect_determine_vf_for_stmt (stmt_vec_inf && STMT_VINFO_RELATED_STMT (stmt_info)) { gimple *pattern_def_seq = STMT_VINFO_PATTERN_DEF_SEQ (stmt_info); - stmt_info = vinfo_for_stmt (STMT_VINFO_RELATED_STMT (stmt_info)); + stmt_info = STMT_VINFO_RELATED_STMT (stmt_info); /* If a pattern statement has def stmts, analyze them too. */ for (gimple_stmt_iterator si = gsi_start (pattern_def_seq); @@ -654,23 +654,23 @@ vect_analyze_scalar_cycles (loop_vec_inf static void vect_fixup_reduc_chain (gimple *stmt) { - gimple *firstp = STMT_VINFO_RELATED_STMT (vinfo_for_stmt (stmt)); - gimple *stmtp; - gcc_assert (!REDUC_GROUP_FIRST_ELEMENT (vinfo_for_stmt (firstp)) - && REDUC_GROUP_FIRST_ELEMENT (vinfo_for_stmt (stmt))); - REDUC_GROUP_SIZE (vinfo_for_stmt (firstp)) - = REDUC_GROUP_SIZE (vinfo_for_stmt (stmt)); + stmt_vec_info stmt_info = vinfo_for_stmt (stmt); + stmt_vec_info firstp = STMT_VINFO_RELATED_STMT (stmt_info); + stmt_vec_info stmtp; + gcc_assert (!REDUC_GROUP_FIRST_ELEMENT (firstp) + && REDUC_GROUP_FIRST_ELEMENT (stmt_info)); + REDUC_GROUP_SIZE (firstp) = REDUC_GROUP_SIZE (stmt_info); do { stmtp = STMT_VINFO_RELATED_STMT (vinfo_for_stmt (stmt)); - REDUC_GROUP_FIRST_ELEMENT (vinfo_for_stmt (stmtp)) = firstp; + REDUC_GROUP_FIRST_ELEMENT (stmtp) = firstp; stmt = REDUC_GROUP_NEXT_ELEMENT (vinfo_for_stmt (stmt)); if (stmt) - REDUC_GROUP_NEXT_ELEMENT (vinfo_for_stmt (stmtp)) + REDUC_GROUP_NEXT_ELEMENT (stmtp) = STMT_VINFO_RELATED_STMT (vinfo_for_stmt (stmt)); } while (stmt); - STMT_VINFO_DEF_TYPE (vinfo_for_stmt (stmtp)) = vect_reduction_def; + STMT_VINFO_DEF_TYPE (stmtp) = vect_reduction_def; } /* Fixup scalar cycles that now have their stmts detected as patterns. */ @@ -1436,14 +1436,10 @@ vect_update_vf_for_slp (loop_vec_info lo for (gimple_stmt_iterator si = gsi_start_bb (bb); !gsi_end_p (si); gsi_next (&si)) { - gimple *stmt = gsi_stmt (si); stmt_vec_info stmt_info = loop_vinfo->lookup_stmt (gsi_stmt (si)); if (STMT_VINFO_IN_PATTERN_P (stmt_info) && STMT_VINFO_RELATED_STMT (stmt_info)) - { - stmt = STMT_VINFO_RELATED_STMT (stmt_info); - stmt_info = vinfo_for_stmt (stmt); - } + stmt_info = STMT_VINFO_RELATED_STMT (stmt_info); if ((STMT_VINFO_RELEVANT_P (stmt_info) || VECTORIZABLE_CYCLE_DEF (STMT_VINFO_DEF_TYPE (stmt_info))) && !PURE_SLP_STMT (stmt_info)) @@ -2247,7 +2243,7 @@ vect_analyze_loop_2 (loop_vec_info loop_ if (STMT_VINFO_IN_PATTERN_P (stmt_info)) { gimple *pattern_def_seq = STMT_VINFO_PATTERN_DEF_SEQ (stmt_info); - stmt_info = vinfo_for_stmt (STMT_VINFO_RELATED_STMT (stmt_info)); + stmt_info = STMT_VINFO_RELATED_STMT (stmt_info); STMT_SLP_TYPE (stmt_info) = loop_vect; for (gimple_stmt_iterator pi = gsi_start (pattern_def_seq); !gsi_end_p (pi); gsi_next (&pi)) @@ -3836,7 +3832,6 @@ vect_model_reduction_cost (stmt_vec_info enum tree_code code; optab optab; tree vectype; - gimple *orig_stmt; machine_mode mode; loop_vec_info loop_vinfo = STMT_VINFO_LOOP_VINFO (stmt_info); struct loop *loop = NULL; @@ -3852,12 +3847,12 @@ vect_model_reduction_cost (stmt_vec_info vectype = STMT_VINFO_VECTYPE (stmt_info); mode = TYPE_MODE (vectype); - orig_stmt = STMT_VINFO_RELATED_STMT (stmt_info); + stmt_vec_info orig_stmt_info = STMT_VINFO_RELATED_STMT (stmt_info); - if (!orig_stmt) - orig_stmt = STMT_VINFO_STMT (stmt_info); + if (!orig_stmt_info) + orig_stmt_info = stmt_info; - code = gimple_assign_rhs_code (orig_stmt); + code = gimple_assign_rhs_code (orig_stmt_info->stmt); if (reduction_type == EXTRACT_LAST_REDUCTION || reduction_type == FOLD_LEFT_REDUCTION) @@ -3902,7 +3897,7 @@ vect_model_reduction_cost (stmt_vec_info We have a reduction operator that will reduce the vector in one statement. Also requires scalar extract. */ - if (!loop || !nested_in_vect_loop_p (loop, orig_stmt)) + if (!loop || !nested_in_vect_loop_p (loop, orig_stmt_info)) { if (reduc_fn != IFN_LAST) { @@ -3953,7 +3948,7 @@ vect_model_reduction_cost (stmt_vec_info { int vec_size_in_bits = tree_to_uhwi (TYPE_SIZE (vectype)); tree bitsize = - TYPE_SIZE (TREE_TYPE (gimple_assign_lhs (orig_stmt))); + TYPE_SIZE (TREE_TYPE (gimple_assign_lhs (orig_stmt_info->stmt))); int element_bitsize = tree_to_uhwi (bitsize); int nelements = vec_size_in_bits / element_bitsize; @@ -4447,7 +4442,7 @@ vect_create_epilog_for_reduction (vec new_phis; auto_vec inner_phis; @@ -4726,7 +4721,7 @@ vect_create_epilog_for_reduction (vecdest_idx, def); @@ -4758,7 +4753,7 @@ vect_create_epilog_for_reduction (vecdest_idx, PHI_RESULT (phi)); stmt_vec_info outer_phi_info = loop_vinfo->add_stmt (outer_phi); - STMT_VINFO_RELATED_STMT (prev_phi_info) = outer_phi; + STMT_VINFO_RELATED_STMT (prev_phi_info) = outer_phi_info; prev_phi_info = outer_phi_info; } } @@ -4775,27 +4770,26 @@ vect_create_epilog_for_reduction (vecstmt); /* For MINUS_EXPR the initial vector is [init_val,0,...,0], therefore, partial results are added and not subtracted. */ if (code == MINUS_EXPR) code = PLUS_EXPR; - scalar_dest = gimple_assign_lhs (orig_stmt); + scalar_dest = gimple_assign_lhs (orig_stmt_info->stmt); scalar_type = TREE_TYPE (scalar_dest); scalar_results.create (group_size); new_scalar_dest = vect_create_destination_var (scalar_dest, NULL); @@ -5613,10 +5607,11 @@ vect_create_epilog_for_reduction (vecstmt); gcc_assert (vectype_out); vec_mode = TYPE_MODE (vectype_out); } @@ -7757,7 +7749,7 @@ vectorizable_induction (gimple *phi, gsi_insert_before (&si, new_stmt, GSI_SAME_STMT); new_stmt_info = loop_vinfo->add_stmt (new_stmt); - STMT_VINFO_RELATED_STMT (prev_stmt_vinfo) = new_stmt; + STMT_VINFO_RELATED_STMT (prev_stmt_vinfo) = new_stmt_info; prev_stmt_vinfo = new_stmt_info; } } Index: gcc/tree-vect-patterns.c =================================================================== --- gcc/tree-vect-patterns.c 2018-07-24 10:22:37.253248202 +0100 +++ gcc/tree-vect-patterns.c 2018-07-24 10:22:44.289185723 +0100 @@ -94,10 +94,11 @@ vect_pattern_detected (const char *name, } } -/* Associate pattern statement PATTERN_STMT with ORIG_STMT_INFO. - Set its vector type to VECTYPE if it doesn't have one already. */ +/* Associate pattern statement PATTERN_STMT with ORIG_STMT_INFO and + return the pattern statement's stmt_vec_info. Set its vector type to + VECTYPE if it doesn't have one already. */ -static void +static stmt_vec_info vect_init_pattern_stmt (gimple *pattern_stmt, stmt_vec_info orig_stmt_info, tree vectype) { @@ -107,11 +108,12 @@ vect_init_pattern_stmt (gimple *pattern_ pattern_stmt_info = orig_stmt_info->vinfo->add_stmt (pattern_stmt); gimple_set_bb (pattern_stmt, gimple_bb (orig_stmt_info->stmt)); - STMT_VINFO_RELATED_STMT (pattern_stmt_info) = orig_stmt_info->stmt; + STMT_VINFO_RELATED_STMT (pattern_stmt_info) = orig_stmt_info; STMT_VINFO_DEF_TYPE (pattern_stmt_info) = STMT_VINFO_DEF_TYPE (orig_stmt_info); if (!STMT_VINFO_VECTYPE (pattern_stmt_info)) STMT_VINFO_VECTYPE (pattern_stmt_info) = vectype; + return pattern_stmt_info; } /* Set the pattern statement of ORIG_STMT_INFO to PATTERN_STMT. @@ -123,8 +125,8 @@ vect_set_pattern_stmt (gimple *pattern_s tree vectype) { STMT_VINFO_IN_PATTERN_P (orig_stmt_info) = true; - STMT_VINFO_RELATED_STMT (orig_stmt_info) = pattern_stmt; - vect_init_pattern_stmt (pattern_stmt, orig_stmt_info, vectype); + STMT_VINFO_RELATED_STMT (orig_stmt_info) + = vect_init_pattern_stmt (pattern_stmt, orig_stmt_info, vectype); } /* Add NEW_STMT to STMT_INFO's pattern definition statements. If VECTYPE @@ -634,8 +636,7 @@ vect_split_statement (stmt_vec_info stmt { /* STMT2_INFO is part of a pattern. Get the statement to which the pattern is attached. */ - stmt_vec_info orig_stmt2_info - = vinfo_for_stmt (STMT_VINFO_RELATED_STMT (stmt2_info)); + stmt_vec_info orig_stmt2_info = STMT_VINFO_RELATED_STMT (stmt2_info); vect_init_pattern_stmt (stmt1, orig_stmt2_info, vectype); if (dump_enabled_p ()) @@ -659,7 +660,7 @@ vect_split_statement (stmt_vec_info stmt } gimple_seq *def_seq = &STMT_VINFO_PATTERN_DEF_SEQ (orig_stmt2_info); - if (STMT_VINFO_RELATED_STMT (orig_stmt2_info) == stmt2_info->stmt) + if (STMT_VINFO_RELATED_STMT (orig_stmt2_info) == stmt2_info) /* STMT2_INFO is the actual pattern statement. Add STMT1 to the end of the definition sequence. */ gimple_seq_add_stmt_without_update (def_seq, stmt1); @@ -4754,8 +4755,7 @@ vect_mark_pattern_stmts (gimple *orig_st } /* Switch to the statement that ORIG replaces. */ - orig_stmt_info - = vinfo_for_stmt (STMT_VINFO_RELATED_STMT (orig_stmt_info)); + orig_stmt_info = STMT_VINFO_RELATED_STMT (orig_stmt_info); /* We shouldn't be replacing the main pattern statement. */ gcc_assert (STMT_VINFO_RELATED_STMT (orig_stmt_info) != orig_stmt); Index: gcc/tree-vect-slp.c =================================================================== --- gcc/tree-vect-slp.c 2018-07-24 10:22:37.253248202 +0100 +++ gcc/tree-vect-slp.c 2018-07-24 10:22:44.293185688 +0100 @@ -2327,7 +2327,7 @@ vect_detect_hybrid_slp_stmts (slp_tree n original stmt for immediate uses. */ if (! STMT_VINFO_IN_PATTERN_P (stmt_vinfo) && STMT_VINFO_RELATED_STMT (stmt_vinfo)) - stmt = STMT_VINFO_RELATED_STMT (stmt_vinfo); + stmt = STMT_VINFO_RELATED_STMT (stmt_vinfo)->stmt; tree def; if (gimple_code (stmt) == GIMPLE_PHI) def = gimple_phi_result (stmt); @@ -2341,7 +2341,7 @@ vect_detect_hybrid_slp_stmts (slp_tree n continue; if (STMT_VINFO_IN_PATTERN_P (use_vinfo) && STMT_VINFO_RELATED_STMT (use_vinfo)) - use_vinfo = vinfo_for_stmt (STMT_VINFO_RELATED_STMT (use_vinfo)); + use_vinfo = STMT_VINFO_RELATED_STMT (use_vinfo); if (!STMT_SLP_TYPE (use_vinfo) && (STMT_VINFO_RELEVANT (use_vinfo) || VECTORIZABLE_CYCLE_DEF (STMT_VINFO_DEF_TYPE (use_vinfo))) @@ -2446,7 +2446,7 @@ vect_detect_hybrid_slp (loop_vec_info lo memset (&wi, 0, sizeof (wi)); wi.info = loop_vinfo; gimple_stmt_iterator gsi2 - = gsi_for_stmt (STMT_VINFO_RELATED_STMT (stmt_info)); + = gsi_for_stmt (STMT_VINFO_RELATED_STMT (stmt_info)->stmt); walk_gimple_stmt (&gsi2, vect_detect_hybrid_slp_2, vect_detect_hybrid_slp_1, &wi); walk_gimple_seq (STMT_VINFO_PATTERN_DEF_SEQ (stmt_info), @@ -3612,7 +3612,7 @@ vect_get_slp_defs (vec ops, slp_tr if (SLP_TREE_DEF_TYPE (child) == vect_internal_def) { gimple *first_def = SLP_TREE_SCALAR_STMTS (child)[0]; - gimple *related + stmt_vec_info related = STMT_VINFO_RELATED_STMT (vinfo_for_stmt (first_def)); tree first_def_op; @@ -3622,7 +3622,8 @@ vect_get_slp_defs (vec ops, slp_tr first_def_op = gimple_get_lhs (first_def); if (operand_equal_p (oprnd, first_def_op, 0) || (related - && operand_equal_p (oprnd, gimple_get_lhs (related), 0))) + && operand_equal_p (oprnd, + gimple_get_lhs (related->stmt), 0))) { /* The number of vector defs is determined by the number of vector statements in the node from which we get those Index: gcc/tree-vect-stmts.c =================================================================== --- gcc/tree-vect-stmts.c 2018-07-24 10:22:40.725217371 +0100 +++ gcc/tree-vect-stmts.c 2018-07-24 10:22:44.293185688 +0100 @@ -202,7 +202,6 @@ vect_mark_relevant (vec *workl stmt_vec_info stmt_info = vinfo_for_stmt (stmt); enum vect_relevant save_relevant = STMT_VINFO_RELEVANT (stmt_info); bool save_live_p = STMT_VINFO_LIVE_P (stmt_info); - gimple *pattern_stmt; if (dump_enabled_p ()) { @@ -222,17 +221,16 @@ vect_mark_relevant (vec *workl as relevant/live because it's not going to be vectorized. Instead mark the pattern-stmt that replaces it. */ - pattern_stmt = STMT_VINFO_RELATED_STMT (stmt_info); - if (dump_enabled_p ()) dump_printf_loc (MSG_NOTE, vect_location, "last stmt in pattern. don't mark" " relevant/live.\n"); - stmt_info = vinfo_for_stmt (pattern_stmt); - gcc_assert (STMT_VINFO_RELATED_STMT (stmt_info) == stmt); + stmt_vec_info old_stmt_info = stmt_info; + stmt_info = STMT_VINFO_RELATED_STMT (stmt_info); + gcc_assert (STMT_VINFO_RELATED_STMT (stmt_info) == old_stmt_info); save_relevant = STMT_VINFO_RELEVANT (stmt_info); save_live_p = STMT_VINFO_LIVE_P (stmt_info); - stmt = pattern_stmt; + stmt = stmt_info->stmt; } STMT_VINFO_LIVE_P (stmt_info) |= live_p; @@ -1489,8 +1487,8 @@ vect_get_vec_def_for_operand_1 (gimple * if (!vec_stmt && STMT_VINFO_IN_PATTERN_P (def_stmt_info) && !STMT_VINFO_RELEVANT (def_stmt_info)) - vec_stmt = STMT_VINFO_VEC_STMT (vinfo_for_stmt ( - STMT_VINFO_RELATED_STMT (def_stmt_info))); + vec_stmt = (STMT_VINFO_VEC_STMT + (STMT_VINFO_RELATED_STMT (def_stmt_info))); gcc_assert (vec_stmt); if (gimple_code (vec_stmt) == GIMPLE_PHI) vec_oprnd = PHI_RESULT (vec_stmt); @@ -3635,7 +3633,7 @@ vectorizable_call (gimple *gs, gimple_st return true; if (is_pattern_stmt_p (stmt_info)) - stmt_info = vinfo_for_stmt (STMT_VINFO_RELATED_STMT (stmt_info)); + stmt_info = STMT_VINFO_RELATED_STMT (stmt_info); lhs = gimple_get_lhs (stmt_info->stmt); gassign *new_stmt @@ -4370,7 +4368,7 @@ vectorizable_simd_clone_call (gimple *st { type = TREE_TYPE (scalar_dest); if (is_pattern_stmt_p (stmt_info)) - lhs = gimple_call_lhs (STMT_VINFO_RELATED_STMT (stmt_info)); + lhs = gimple_call_lhs (STMT_VINFO_RELATED_STMT (stmt_info)->stmt); else lhs = gimple_call_lhs (stmt); new_stmt = gimple_build_assign (lhs, build_zero_cst (type)); @@ -9420,7 +9418,6 @@ vect_analyze_stmt (gimple *stmt, bool *n bb_vec_info bb_vinfo = STMT_VINFO_BB_VINFO (stmt_info); enum vect_relevant relevance = STMT_VINFO_RELEVANT (stmt_info); bool ok; - gimple *pattern_stmt; gimple_seq pattern_def_seq; if (dump_enabled_p ()) @@ -9482,18 +9479,18 @@ vect_analyze_stmt (gimple *stmt, bool *n traversal, don't analyze pattern stmts instead, the pattern stmts already will be part of SLP instance. */ - pattern_stmt = STMT_VINFO_RELATED_STMT (stmt_info); + stmt_vec_info pattern_stmt_info = STMT_VINFO_RELATED_STMT (stmt_info); if (!STMT_VINFO_RELEVANT_P (stmt_info) && !STMT_VINFO_LIVE_P (stmt_info)) { if (STMT_VINFO_IN_PATTERN_P (stmt_info) - && pattern_stmt - && (STMT_VINFO_RELEVANT_P (vinfo_for_stmt (pattern_stmt)) - || STMT_VINFO_LIVE_P (vinfo_for_stmt (pattern_stmt)))) + && pattern_stmt_info + && (STMT_VINFO_RELEVANT_P (pattern_stmt_info) + || STMT_VINFO_LIVE_P (pattern_stmt_info))) { /* Analyze PATTERN_STMT instead of the original stmt. */ - stmt = pattern_stmt; - stmt_info = vinfo_for_stmt (pattern_stmt); + stmt = pattern_stmt_info->stmt; + stmt_info = pattern_stmt_info; if (dump_enabled_p ()) { dump_printf_loc (MSG_NOTE, vect_location, @@ -9511,9 +9508,9 @@ vect_analyze_stmt (gimple *stmt, bool *n } else if (STMT_VINFO_IN_PATTERN_P (stmt_info) && node == NULL - && pattern_stmt - && (STMT_VINFO_RELEVANT_P (vinfo_for_stmt (pattern_stmt)) - || STMT_VINFO_LIVE_P (vinfo_for_stmt (pattern_stmt)))) + && pattern_stmt_info + && (STMT_VINFO_RELEVANT_P (pattern_stmt_info) + || STMT_VINFO_LIVE_P (pattern_stmt_info))) { /* Analyze PATTERN_STMT too. */ if (dump_enabled_p ()) @@ -9523,7 +9520,7 @@ vect_analyze_stmt (gimple *stmt, bool *n dump_gimple_stmt (MSG_NOTE, TDF_SLIM, stmt, 0); } - if (!vect_analyze_stmt (pattern_stmt, need_to_vectorize, node, + if (!vect_analyze_stmt (pattern_stmt_info, need_to_vectorize, node, node_instance, cost_vec)) return false; } @@ -9855,7 +9852,6 @@ new_stmt_vec_info (gimple *stmt, vec_inf STMT_VINFO_VEC_STMT (res) = NULL; STMT_VINFO_VECTORIZABLE (res) = true; STMT_VINFO_IN_PATTERN_P (res) = false; - STMT_VINFO_RELATED_STMT (res) = NULL; STMT_VINFO_PATTERN_DEF_SEQ (res) = NULL; STMT_VINFO_DATA_REF (res) = NULL; STMT_VINFO_VEC_REDUCTION_TYPE (res) = TREE_CODE_REDUCTION; @@ -9936,16 +9932,14 @@ free_stmt_vec_info (gimple *stmt) release_ssa_name (lhs); free_stmt_vec_info (seq_stmt); } - stmt_vec_info patt_info - = vinfo_for_stmt (STMT_VINFO_RELATED_STMT (stmt_info)); - if (patt_info) - { - gimple *patt_stmt = STMT_VINFO_STMT (patt_info); - gimple_set_bb (patt_stmt, NULL); - tree lhs = gimple_get_lhs (patt_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); + free_stmt_vec_info (patt_stmt_info); } } @@ -10143,8 +10137,8 @@ vect_is_simple_use (tree operand, vec_in { if (STMT_VINFO_IN_PATTERN_P (stmt_vinfo)) { - def_stmt = STMT_VINFO_RELATED_STMT (stmt_vinfo); - stmt_vinfo = vinfo_for_stmt (def_stmt); + stmt_vinfo = STMT_VINFO_RELATED_STMT (stmt_vinfo); + def_stmt = stmt_vinfo->stmt; } switch (gimple_code (def_stmt)) {