From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 119170 invoked by alias); 24 Jul 2018 10:07:19 -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 118285 invoked by uid 89); 24 Jul 2018 10:07:18 -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:07:16 +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 F29CE7A9 for ; Tue, 24 Jul 2018 03:07:14 -0700 (PDT) Received: from localhost (unknown [10.32.99.48]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7B3973F237 for ; Tue, 24 Jul 2018 03:07:14 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [36/46] Add a pattern_stmt_p field to stmt_vec_info References: <87wotlrmen.fsf@arm.com> Date: Tue, 24 Jul 2018 10:07:00 -0000 In-Reply-To: <87wotlrmen.fsf@arm.com> (Richard Sandiford's message of "Tue, 24 Jul 2018 10:52:16 +0100") Message-ID: <87lga1lzfz.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/msg01345.txt.bz2 This patch adds a pattern_stmt_p field to stmt_vec_info, so that it's possible to tell whether the statement is a pattern statement without referring to other statements. The new field goes in what was previously a hole in the structure, so the size is the same as before. 2018-07-24 Richard Sandiford gcc/ * tree-vectorizer.h (_stmt_vec_info::pattern_stmt_p): New field. (is_pattern_stmt_p): Delete. * tree-vect-patterns.c (vect_init_pattern_stmt): Set pattern_stmt_p on pattern statements. (vect_split_statement, vect_mark_pattern_stmts): Use the new pattern_stmt_p field instead of is_pattern_stmt_p. * tree-vect-data-refs.c (vect_preserves_scalar_order_p): Likewise. * tree-vect-loop.c (vectorizable_live_operation): Likewise. * tree-vect-slp.c (vect_build_slp_tree_2): Likewise. (vect_find_last_scalar_stmt_in_slp, vect_remove_slp_scalar_calls) (vect_schedule_slp): Likewise. * tree-vect-stmts.c (vect_mark_stmts_to_be_vectorized): Likewise. (vectorizable_call, vectorizable_simd_clone_call, vectorizable_shift) (vectorizable_store, vect_remove_stores): Likewise. Index: gcc/tree-vectorizer.h =================================================================== --- gcc/tree-vectorizer.h 2018-07-24 10:23:56.440544995 +0100 +++ gcc/tree-vectorizer.h 2018-07-24 10:24:02.364492386 +0100 @@ -791,6 +791,12 @@ struct _stmt_vec_info { /* Stmt is part of some pattern (computation idiom) */ bool in_pattern_p; + /* True if the statement was created during pattern recognition as + part of the replacement for RELATED_STMT. This implies that the + statement isn't part of any basic block, although for convenience + its gimple_bb is the same as for RELATED_STMT. */ + bool pattern_stmt_p; + /* Is this statement vectorizable or should it be skipped in (partial) vectorization. */ bool vectorizable; @@ -1151,16 +1157,6 @@ get_later_stmt (stmt_vec_info stmt1_info return stmt2_info; } -/* Return TRUE if a statement represented by STMT_INFO is a part of a - pattern. */ - -static inline bool -is_pattern_stmt_p (stmt_vec_info stmt_info) -{ - 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. */ static inline bool Index: gcc/tree-vect-patterns.c =================================================================== --- gcc/tree-vect-patterns.c 2018-07-24 10:23:59.408518638 +0100 +++ gcc/tree-vect-patterns.c 2018-07-24 10:24:02.360492422 +0100 @@ -108,6 +108,7 @@ 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)); + pattern_stmt_info->pattern_stmt_p = true; STMT_VINFO_RELATED_STMT (pattern_stmt_info) = orig_stmt_info; STMT_VINFO_DEF_TYPE (pattern_stmt_info) = STMT_VINFO_DEF_TYPE (orig_stmt_info); @@ -630,7 +631,7 @@ vect_recog_temp_ssa_var (tree type, gimp vect_split_statement (stmt_vec_info stmt2_info, tree new_rhs, gimple *stmt1, tree vectype) { - if (is_pattern_stmt_p (stmt2_info)) + if (stmt2_info->pattern_stmt_p) { /* STMT2_INFO is part of a pattern. Get the statement to which the pattern is attached. */ @@ -4726,7 +4727,7 @@ vect_mark_pattern_stmts (stmt_vec_info o gimple *def_seq = STMT_VINFO_PATTERN_DEF_SEQ (orig_stmt_info); gimple *orig_pattern_stmt = NULL; - if (is_pattern_stmt_p (orig_stmt_info)) + if (orig_stmt_info->pattern_stmt_p) { /* We're replacing a statement in an existing pattern definition sequence. */ Index: gcc/tree-vect-data-refs.c =================================================================== --- gcc/tree-vect-data-refs.c 2018-07-24 10:23:53.204573732 +0100 +++ gcc/tree-vect-data-refs.c 2018-07-24 10:24:02.356492457 +0100 @@ -212,9 +212,9 @@ vect_preserves_scalar_order_p (stmt_vec_ (but could happen later) while reads will happen no later than their 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)) + if (stmtinfo_a->pattern_stmt_p) stmtinfo_a = STMT_VINFO_RELATED_STMT (stmtinfo_a); - if (is_pattern_stmt_p (stmtinfo_b)) + if (stmtinfo_b->pattern_stmt_p) stmtinfo_b = STMT_VINFO_RELATED_STMT (stmtinfo_b); stmt_vec_info earlier_stmt_info = get_earlier_stmt (stmtinfo_a, stmtinfo_b); return !DR_IS_WRITE (STMT_VINFO_DATA_REF (earlier_stmt_info)); Index: gcc/tree-vect-loop.c =================================================================== --- gcc/tree-vect-loop.c 2018-07-24 10:23:56.436545030 +0100 +++ gcc/tree-vect-loop.c 2018-07-24 10:24:02.360492422 +0100 @@ -7907,7 +7907,7 @@ vectorizable_live_operation (stmt_vec_in } /* If stmt has a related stmt, then use that for getting the lhs. */ - gimple *stmt = (is_pattern_stmt_p (stmt_info) + gimple *stmt = (stmt_info->pattern_stmt_p ? STMT_VINFO_RELATED_STMT (stmt_info)->stmt : stmt_info->stmt); Index: gcc/tree-vect-slp.c =================================================================== --- gcc/tree-vect-slp.c 2018-07-24 10:23:53.204573732 +0100 +++ gcc/tree-vect-slp.c 2018-07-24 10:24:02.360492422 +0100 @@ -376,7 +376,7 @@ vect_get_and_check_slp_defs (vec_info *v /* Check if DEF_STMT_INFO is a part of a pattern in LOOP and get the def stmt from the pattern. Check that all the stmts of the node are in the pattern. */ - if (def_stmt_info && is_pattern_stmt_p (def_stmt_info)) + if (def_stmt_info && def_stmt_info->pattern_stmt_p) { pattern = true; if (!first && !oprnd_info->first_pattern @@ -1315,7 +1315,7 @@ vect_build_slp_tree_2 (vec_info *vinfo, /* ??? Rejecting patterns this way doesn't work. We'd have to do extra work to cancel the pattern so the uses see the scalar version. */ - && !is_pattern_stmt_p (SLP_TREE_SCALAR_STMTS (child)[0])) + && !SLP_TREE_SCALAR_STMTS (child)[0]->pattern_stmt_p) { slp_tree grandchild; @@ -1359,7 +1359,7 @@ vect_build_slp_tree_2 (vec_info *vinfo, /* ??? Rejecting patterns this way doesn't work. We'd have to do extra work to cancel the pattern so the uses see the scalar version. */ - && !is_pattern_stmt_p (stmt_info)) + && !stmt_info->pattern_stmt_p) { dump_printf_loc (MSG_NOTE, vect_location, "Building vector operands from scalars\n"); @@ -1486,7 +1486,7 @@ vect_build_slp_tree_2 (vec_info *vinfo, /* ??? Rejecting patterns this way doesn't work. We'd have to do extra work to cancel the pattern so the uses see the scalar version. */ - && !is_pattern_stmt_p (SLP_TREE_SCALAR_STMTS (child)[0])) + && !SLP_TREE_SCALAR_STMTS (child)[0]->pattern_stmt_p) { unsigned int j; slp_tree grandchild; @@ -1848,7 +1848,7 @@ vect_find_last_scalar_stmt_in_slp (slp_t for (int i = 0; SLP_TREE_SCALAR_STMTS (node).iterate (i, &stmt_vinfo); i++) { - if (is_pattern_stmt_p (stmt_vinfo)) + if (stmt_vinfo->pattern_stmt_p) stmt_vinfo = STMT_VINFO_RELATED_STMT (stmt_vinfo); last = last ? get_later_stmt (stmt_vinfo, last) : stmt_vinfo; } @@ -4044,8 +4044,7 @@ vect_remove_slp_scalar_calls (slp_tree n gcall *stmt = dyn_cast (stmt_info->stmt); if (!stmt || gimple_bb (stmt) == NULL) continue; - if (is_pattern_stmt_p (stmt_info) - || !PURE_SLP_STMT (stmt_info)) + if (stmt_info->pattern_stmt_p || !PURE_SLP_STMT (stmt_info)) continue; lhs = gimple_call_lhs (stmt); new_stmt = gimple_build_assign (lhs, build_zero_cst (TREE_TYPE (lhs))); @@ -4106,7 +4105,7 @@ vect_schedule_slp (vec_info *vinfo) if (!STMT_VINFO_DATA_REF (store_info)) break; - if (is_pattern_stmt_p (store_info)) + 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); Index: gcc/tree-vect-stmts.c =================================================================== --- gcc/tree-vect-stmts.c 2018-07-24 10:23:56.440544995 +0100 +++ gcc/tree-vect-stmts.c 2018-07-24 10:24:02.364492386 +0100 @@ -731,7 +731,7 @@ vect_mark_stmts_to_be_vectorized (loop_v break; } - if (is_pattern_stmt_p (stmt_vinfo)) + if (stmt_vinfo->pattern_stmt_p) { /* Pattern statements are not inserted into the code, so FOR_EACH_PHI_OR_STMT_USE optimizes their operands out, and we @@ -3623,7 +3623,7 @@ vectorizable_call (stmt_vec_info stmt_in if (slp_node) return true; - if (is_pattern_stmt_p (stmt_info)) + if (stmt_info->pattern_stmt_p) stmt_info = STMT_VINFO_RELATED_STMT (stmt_info); lhs = gimple_get_lhs (stmt_info->stmt); @@ -4362,7 +4362,7 @@ vectorizable_simd_clone_call (stmt_vec_i if (scalar_dest) { type = TREE_TYPE (scalar_dest); - if (is_pattern_stmt_p (stmt_info)) + if (stmt_info->pattern_stmt_p) lhs = gimple_call_lhs (STMT_VINFO_RELATED_STMT (stmt_info)->stmt); else lhs = gimple_call_lhs (stmt); @@ -5552,7 +5552,7 @@ vectorizable_shift (stmt_vec_info stmt_i /* If the shift amount is computed by a pattern stmt we cannot use the scalar amount directly thus give up and use a vector shift. */ - if (op1_def_stmt_info && is_pattern_stmt_p (op1_def_stmt_info)) + if (op1_def_stmt_info && op1_def_stmt_info->pattern_stmt_p) scalar_shift_arg = false; } else @@ -6286,7 +6286,7 @@ vectorizable_store (stmt_vec_info stmt_i { tree scalar_dest = gimple_assign_lhs (assign); if (TREE_CODE (scalar_dest) == VIEW_CONVERT_EXPR - && is_pattern_stmt_p (stmt_info)) + && stmt_info->pattern_stmt_p) scalar_dest = TREE_OPERAND (scalar_dest, 0); if (TREE_CODE (scalar_dest) != ARRAY_REF && TREE_CODE (scalar_dest) != BIT_FIELD_REF @@ -9839,7 +9839,7 @@ vect_remove_stores (stmt_vec_info first_ while (next_stmt_info) { stmt_vec_info tmp = DR_GROUP_NEXT_ELEMENT (next_stmt_info); - if (is_pattern_stmt_p (next_stmt_info)) + 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);