From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14061 invoked by alias); 25 Oct 2019 12:39:15 -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 14053 invoked by uid 89); 25 Oct 2019 12:39:14 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-9.2 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,GIT_PATCH_3,KAM_ASCII_DIVIDERS,SPF_PASS autolearn=ham version=3.3.1 spammy=v16qi X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.110.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 25 Oct 2019 12:39:12 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6C19B28 for ; Fri, 25 Oct 2019 05:39:11 -0700 (PDT) Received: from localhost (e121540-lin.manchester.arm.com [10.32.98.126]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 11B0F3F6C4 for ; Fri, 25 Oct 2019 05:39:10 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [9/n] Replace vec_info::vector_size with vec_info::vector_mode References: Date: Fri, 25 Oct 2019 12:41:00 -0000 In-Reply-To: (Richard Sandiford's message of "Fri, 25 Oct 2019 13:30:08 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2019-10/txt/msg01828.txt.bz2 This patch replaces vec_info::vector_size with vec_info::vector_mode, but for now continues to use it as a way of specifying a single vector size. This makes it easier for later patches to use related_vector_mode instead. 2019-10-24 Richard Sandiford gcc/ * tree-vectorizer.h (vec_info::vector_size): Replace with... (vec_info::vector_mode): ...this new field. * tree-vect-loop.c (vect_update_vf_for_slp): Update accordingly. (vect_analyze_loop, vect_transform_loop): Likewise. * tree-vect-slp.c (can_duplicate_and_interleave_p): Likewise. (vect_make_slp_decision, vect_slp_bb_region): Likewise. * tree-vect-stmts.c (get_vectype_for_scalar_type): Likewise. * tree-vectorizer.c (try_vectorize_loop_1): Likewise. gcc/testsuite/ * gcc.dg/vect/vect-tail-nomask-1.c: Update expected epilogue vectorization message. Index: gcc/tree-vectorizer.h =================================================================== --- gcc/tree-vectorizer.h 2019-10-25 13:26:59.093879082 +0100 +++ gcc/tree-vectorizer.h 2019-10-25 13:27:19.317736181 +0100 @@ -329,9 +329,9 @@ typedef std::pair vec_object /* Cost data used by the target cost model. */ void *target_cost_data; - /* The vector size for this loop in bytes, or 0 if we haven't picked - a size yet. */ - poly_uint64 vector_size; + /* If we've chosen a vector size for this vectorization region, + this is one mode that has such a size, otherwise it is VOIDmode. */ + machine_mode vector_mode; private: stmt_vec_info new_stmt_vec_info (gimple *stmt); Index: gcc/tree-vect-loop.c =================================================================== --- gcc/tree-vect-loop.c 2019-10-25 13:27:15.525762975 +0100 +++ gcc/tree-vect-loop.c 2019-10-25 13:27:19.309736237 +0100 @@ -1414,8 +1414,8 @@ vect_update_vf_for_slp (loop_vec_info lo dump_printf_loc (MSG_NOTE, vect_location, "Loop contains SLP and non-SLP stmts\n"); /* Both the vectorization factor and unroll factor have the form - loop_vinfo->vector_size * X for some rational X, so they must have - a common multiple. */ + GET_MODE_SIZE (loop_vinfo->vector_mode) * X for some rational X, + so they must have a common multiple. */ vectorization_factor = force_common_multiple (vectorization_factor, LOOP_VINFO_SLP_UNROLLING_FACTOR (loop_vinfo)); @@ -2341,7 +2341,7 @@ vect_analyze_loop (class loop *loop, loo " loops cannot be vectorized\n"); unsigned n_stmts = 0; - poly_uint64 autodetected_vector_size = 0; + machine_mode autodetected_vector_mode = VOIDmode; opt_loop_vec_info first_loop_vinfo = opt_loop_vec_info::success (NULL); machine_mode next_vector_mode = VOIDmode; while (1) @@ -2357,7 +2357,7 @@ vect_analyze_loop (class loop *loop, loo gcc_checking_assert (first_loop_vinfo == NULL); return loop_vinfo; } - loop_vinfo->vector_size = GET_MODE_SIZE (next_vector_mode); + loop_vinfo->vector_mode = next_vector_mode; bool fatal = false; @@ -2366,7 +2366,7 @@ vect_analyze_loop (class loop *loop, loo opt_result res = vect_analyze_loop_2 (loop_vinfo, fatal, &n_stmts); if (mode_i == 0) - autodetected_vector_size = loop_vinfo->vector_size; + autodetected_vector_mode = loop_vinfo->vector_mode; if (res) { @@ -2401,21 +2401,21 @@ vect_analyze_loop (class loop *loop, loo if (mode_i < vector_modes.length () && known_eq (GET_MODE_SIZE (vector_modes[mode_i]), - autodetected_vector_size)) + GET_MODE_SIZE (autodetected_vector_mode))) mode_i += 1; if (mode_i == vector_modes.length () - || known_eq (autodetected_vector_size, 0U)) + || autodetected_vector_mode == VOIDmode) { if (first_loop_vinfo) { loop->aux = (loop_vec_info) first_loop_vinfo; if (dump_enabled_p ()) { + machine_mode mode = first_loop_vinfo->vector_mode; dump_printf_loc (MSG_NOTE, vect_location, - "***** Choosing vector size "); - dump_dec (MSG_NOTE, first_loop_vinfo->vector_size); - dump_printf (MSG_NOTE, "\n"); + "***** Choosing vector mode %s\n", + GET_MODE_NAME (mode)); } return first_loop_vinfo; } @@ -8238,12 +8238,9 @@ vect_transform_loop (loop_vec_info loop_ dump_printf (MSG_NOTE, "\n"); } else - { - dump_printf_loc (MSG_NOTE, vect_location, - "LOOP EPILOGUE VECTORIZED (VS="); - dump_dec (MSG_NOTE, loop_vinfo->vector_size); - dump_printf (MSG_NOTE, ")\n"); - } + dump_printf_loc (MSG_NOTE, vect_location, + "LOOP EPILOGUE VECTORIZED (MODE=%s)\n", + GET_MODE_NAME (loop_vinfo->vector_mode)); } /* Loops vectorized with a variable factor won't benefit from @@ -8294,14 +8291,14 @@ vect_transform_loop (loop_vec_info loop_ unsigned int ratio; while (next_i < vector_modes.length () && !(constant_multiple_p - (loop_vinfo->vector_size, + (GET_MODE_SIZE (loop_vinfo->vector_mode), GET_MODE_SIZE (vector_modes[next_i]), &ratio) && eiters >= lowest_vf / ratio)) next_i += 1; } else while (next_i < vector_modes.length () - && maybe_lt (loop_vinfo->vector_size, + && maybe_lt (GET_MODE_SIZE (loop_vinfo->vector_mode), GET_MODE_SIZE (vector_modes[next_i]))) next_i += 1; Index: gcc/tree-vect-slp.c =================================================================== --- gcc/tree-vect-slp.c 2019-10-25 13:27:15.525762975 +0100 +++ gcc/tree-vect-slp.c 2019-10-25 13:27:19.313736209 +0100 @@ -274,7 +274,7 @@ can_duplicate_and_interleave_p (vec_info { scalar_int_mode int_mode; poly_int64 elt_bits = elt_bytes * BITS_PER_UNIT; - if (multiple_p (vinfo->vector_size, elt_bytes, &nelts) + if (multiple_p (GET_MODE_SIZE (vinfo->vector_mode), elt_bytes, &nelts) && int_mode_for_size (elt_bits, 0).exists (&int_mode)) { tree int_type = build_nonstandard_integer_type @@ -474,7 +474,7 @@ vect_get_and_check_slp_defs (vec_info *v } if ((dt == vect_constant_def || dt == vect_external_def) - && !vinfo->vector_size.is_constant () + && !GET_MODE_SIZE (vinfo->vector_mode).is_constant () && (TREE_CODE (type) == BOOLEAN_TYPE || !can_duplicate_and_interleave_p (vinfo, stmts.length (), TYPE_MODE (type)))) @@ -2339,8 +2339,11 @@ vect_make_slp_decision (loop_vec_info lo FOR_EACH_VEC_ELT (slp_instances, i, instance) { /* FORNOW: SLP if you can. */ - /* All unroll factors have the form vinfo->vector_size * X for some - rational X, so they must have a common multiple. */ + /* All unroll factors have the form: + + GET_MODE_SIZE (vinfo->vector_mode) * X + + for some rational X, so they must have a common multiple. */ unrolling_factor = force_common_multiple (unrolling_factor, SLP_INSTANCE_UNROLLING_FACTOR (instance)); @@ -3096,7 +3099,7 @@ vect_slp_bb_region (gimple_stmt_iterator vec_info_shared shared; - poly_uint64 autodetected_vector_size = 0; + machine_mode autodetected_vector_mode = VOIDmode; while (1) { bool vectorized = false; @@ -3109,7 +3112,7 @@ vect_slp_bb_region (gimple_stmt_iterator bb_vinfo->shared->save_datarefs (); else bb_vinfo->shared->check_datarefs (); - bb_vinfo->vector_size = GET_MODE_SIZE (next_vector_mode); + bb_vinfo->vector_mode = next_vector_mode; if (vect_slp_analyze_bb_1 (bb_vinfo, n_stmts, fatal) && dbg_cnt (vect_slp)) @@ -3123,7 +3126,7 @@ vect_slp_bb_region (gimple_stmt_iterator unsigned HOST_WIDE_INT bytes; if (dump_enabled_p ()) { - if (bb_vinfo->vector_size.is_constant (&bytes)) + if (GET_MODE_SIZE (bb_vinfo->vector_mode).is_constant (&bytes)) dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location, "basic block part vectorized using %wu byte " "vectors\n", bytes); @@ -3137,18 +3140,18 @@ vect_slp_bb_region (gimple_stmt_iterator } if (mode_i == 0) - autodetected_vector_size = bb_vinfo->vector_size; + autodetected_vector_mode = bb_vinfo->vector_mode; delete bb_vinfo; if (mode_i < vector_modes.length () && known_eq (GET_MODE_SIZE (vector_modes[mode_i]), - autodetected_vector_size)) + GET_MODE_SIZE (autodetected_vector_mode))) mode_i += 1; if (vectorized || mode_i == vector_modes.length () - || known_eq (autodetected_vector_size, 0U) + || autodetected_vector_mode == VOIDmode /* If vect_slp_analyze_bb_1 signaled that analysis for all vector sizes will fail do not bother iterating. */ || fatal) Index: gcc/tree-vect-stmts.c =================================================================== --- gcc/tree-vect-stmts.c 2019-10-25 13:27:12.121787027 +0100 +++ gcc/tree-vect-stmts.c 2019-10-25 13:27:19.313736209 +0100 @@ -11212,11 +11212,10 @@ get_vectype_for_scalar_type_and_size (tr get_vectype_for_scalar_type (vec_info *vinfo, tree scalar_type) { tree vectype; - vectype = get_vectype_for_scalar_type_and_size (scalar_type, - vinfo->vector_size); - if (vectype - && known_eq (vinfo->vector_size, 0U)) - vinfo->vector_size = GET_MODE_SIZE (TYPE_MODE (vectype)); + poly_uint64 vector_size = GET_MODE_SIZE (vinfo->vector_mode); + vectype = get_vectype_for_scalar_type_and_size (scalar_type, vector_size); + if (vectype && vinfo->vector_mode == VOIDmode) + vinfo->vector_mode = TYPE_MODE (vectype); return vectype; } Index: gcc/tree-vectorizer.c =================================================================== --- gcc/tree-vectorizer.c 2019-10-21 07:41:32.997886232 +0100 +++ gcc/tree-vectorizer.c 2019-10-25 13:27:19.317736181 +0100 @@ -971,7 +971,7 @@ try_vectorize_loop_1 (hash_tablevector_size.is_constant (&bytes)) + if (GET_MODE_SIZE (loop_vinfo->vector_mode).is_constant (&bytes)) dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location, "loop vectorized using %wu byte vectors\n", bytes); else Index: gcc/testsuite/gcc.dg/vect/vect-tail-nomask-1.c =================================================================== --- gcc/testsuite/gcc.dg/vect/vect-tail-nomask-1.c 2019-03-08 18:15:02.260871260 +0000 +++ gcc/testsuite/gcc.dg/vect/vect-tail-nomask-1.c 2019-10-25 13:27:19.309736237 +0100 @@ -106,4 +106,4 @@ main (int argc, const char **argv) } /* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 2 "vect" { target avx2_runtime } } } */ -/* { dg-final { scan-tree-dump-times "LOOP EPILOGUE VECTORIZED \\(VS=16\\)" 2 "vect" { target avx2_runtime } } } */ +/* { dg-final { scan-tree-dump-times "LOOP EPILOGUE VECTORIZED \\(MODE=V16QI\\)" 2 "vect" { target avx2_runtime } } } */