Commit 1c84a2d2 by Richard Sandiford Committed by Richard Sandiford

Replace vec_info::vector_size with vec_info::vector_mode

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-11-14  Richard Sandiford  <richard.sandiford@arm.com>

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-loop-manip.c (vect_do_peeling): 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.

From-SVN: r278237
parent e021fb86
2019-11-14 Richard Sandiford <richard.sandiford@arm.com> 2019-11-14 Richard Sandiford <richard.sandiford@arm.com>
* 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-loop-manip.c (vect_do_peeling): 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.
2019-11-14 Richard Sandiford <richard.sandiford@arm.com>
* target.h (vector_sizes, auto_vector_sizes): Delete. * target.h (vector_sizes, auto_vector_sizes): Delete.
(vector_modes, auto_vector_modes): New typedefs. (vector_modes, auto_vector_modes): New typedefs.
* target.def (autovectorize_vector_sizes): Replace with... * target.def (autovectorize_vector_sizes): Replace with...
2019-11-14 Richard Sandiford <richard.sandiford@arm.com>
* gcc.dg/vect/vect-tail-nomask-1.c: Update expected epilogue
vectorization message.
2019-11-14 Richard Henderson <richard.henderson@linaro.org> 2019-11-14 Richard Henderson <richard.henderson@linaro.org>
* gcc.target/aarch64/asm-flag-1.c: New test. * gcc.target/aarch64/asm-flag-1.c: New test.
......
...@@ -106,4 +106,4 @@ main (int argc, const char **argv) ...@@ -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 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 } } } */
...@@ -2538,8 +2538,9 @@ vect_do_peeling (loop_vec_info loop_vinfo, tree niters, tree nitersm1, ...@@ -2538,8 +2538,9 @@ vect_do_peeling (loop_vec_info loop_vinfo, tree niters, tree nitersm1,
unsigned int ratio; unsigned int ratio;
unsigned int epilogue_gaps unsigned int epilogue_gaps
= LOOP_VINFO_PEELING_FOR_GAPS (epilogue_vinfo); = LOOP_VINFO_PEELING_FOR_GAPS (epilogue_vinfo);
while (!(constant_multiple_p (loop_vinfo->vector_size, while (!(constant_multiple_p
epilogue_vinfo->vector_size, &ratio) (GET_MODE_SIZE (loop_vinfo->vector_mode),
GET_MODE_SIZE (epilogue_vinfo->vector_mode), &ratio)
&& eiters >= lowest_vf / ratio + epilogue_gaps)) && eiters >= lowest_vf / ratio + epilogue_gaps))
{ {
delete epilogue_vinfo; delete epilogue_vinfo;
......
...@@ -1422,8 +1422,8 @@ vect_update_vf_for_slp (loop_vec_info loop_vinfo) ...@@ -1422,8 +1422,8 @@ vect_update_vf_for_slp (loop_vec_info loop_vinfo)
dump_printf_loc (MSG_NOTE, vect_location, dump_printf_loc (MSG_NOTE, vect_location,
"Loop contains SLP and non-SLP stmts\n"); "Loop contains SLP and non-SLP stmts\n");
/* Both the vectorization factor and unroll factor have the form /* Both the vectorization factor and unroll factor have the form
loop_vinfo->vector_size * X for some rational X, so they must have GET_MODE_SIZE (loop_vinfo->vector_mode) * X for some rational X,
a common multiple. */ so they must have a common multiple. */
vectorization_factor vectorization_factor
= force_common_multiple (vectorization_factor, = force_common_multiple (vectorization_factor,
LOOP_VINFO_SLP_UNROLLING_FACTOR (loop_vinfo)); LOOP_VINFO_SLP_UNROLLING_FACTOR (loop_vinfo));
...@@ -2404,7 +2404,7 @@ vect_analyze_loop (class loop *loop, vec_info_shared *shared) ...@@ -2404,7 +2404,7 @@ vect_analyze_loop (class loop *loop, vec_info_shared *shared)
" loops cannot be vectorized\n"); " loops cannot be vectorized\n");
unsigned n_stmts = 0; 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); opt_loop_vec_info first_loop_vinfo = opt_loop_vec_info::success (NULL);
machine_mode next_vector_mode = VOIDmode; machine_mode next_vector_mode = VOIDmode;
poly_uint64 lowest_th = 0; poly_uint64 lowest_th = 0;
...@@ -2425,7 +2425,7 @@ vect_analyze_loop (class loop *loop, vec_info_shared *shared) ...@@ -2425,7 +2425,7 @@ vect_analyze_loop (class loop *loop, vec_info_shared *shared)
gcc_checking_assert (first_loop_vinfo == NULL); gcc_checking_assert (first_loop_vinfo == NULL);
return loop_vinfo; return loop_vinfo;
} }
loop_vinfo->vector_size = GET_MODE_SIZE (next_vector_mode); loop_vinfo->vector_mode = next_vector_mode;
bool fatal = false; bool fatal = false;
...@@ -2434,7 +2434,7 @@ vect_analyze_loop (class loop *loop, vec_info_shared *shared) ...@@ -2434,7 +2434,7 @@ vect_analyze_loop (class loop *loop, vec_info_shared *shared)
res = vect_analyze_loop_2 (loop_vinfo, fatal, &n_stmts); res = vect_analyze_loop_2 (loop_vinfo, fatal, &n_stmts);
if (mode_i == 0) if (mode_i == 0)
autodetected_vector_size = loop_vinfo->vector_size; autodetected_vector_mode = loop_vinfo->vector_mode;
loop->aux = NULL; loop->aux = NULL;
if (res) if (res)
...@@ -2502,11 +2502,11 @@ vect_analyze_loop (class loop *loop, vec_info_shared *shared) ...@@ -2502,11 +2502,11 @@ vect_analyze_loop (class loop *loop, vec_info_shared *shared)
if (mode_i < vector_modes.length () if (mode_i < vector_modes.length ()
&& known_eq (GET_MODE_SIZE (vector_modes[mode_i]), && known_eq (GET_MODE_SIZE (vector_modes[mode_i]),
autodetected_vector_size)) GET_MODE_SIZE (autodetected_vector_mode)))
mode_i += 1; mode_i += 1;
if (mode_i == vector_modes.length () if (mode_i == vector_modes.length ()
|| known_eq (autodetected_vector_size, 0U)) || autodetected_vector_mode == VOIDmode)
break; break;
/* Try the next biggest vector size. */ /* Try the next biggest vector size. */
...@@ -2521,12 +2521,9 @@ vect_analyze_loop (class loop *loop, vec_info_shared *shared) ...@@ -2521,12 +2521,9 @@ vect_analyze_loop (class loop *loop, vec_info_shared *shared)
{ {
loop->aux = (loop_vec_info) first_loop_vinfo; loop->aux = (loop_vec_info) first_loop_vinfo;
if (dump_enabled_p ()) if (dump_enabled_p ())
{ dump_printf_loc (MSG_NOTE, vect_location,
dump_printf_loc (MSG_NOTE, vect_location, "***** Choosing vector mode %s\n",
"***** Choosing vector size "); GET_MODE_NAME (first_loop_vinfo->vector_mode));
dump_dec (MSG_NOTE, first_loop_vinfo->vector_size);
dump_printf (MSG_NOTE, "\n");
}
LOOP_VINFO_VERSIONING_THRESHOLD (first_loop_vinfo) = lowest_th; LOOP_VINFO_VERSIONING_THRESHOLD (first_loop_vinfo) = lowest_th;
return first_loop_vinfo; return first_loop_vinfo;
} }
...@@ -8580,12 +8577,9 @@ vect_transform_loop (loop_vec_info loop_vinfo) ...@@ -8580,12 +8577,9 @@ vect_transform_loop (loop_vec_info loop_vinfo)
dump_printf (MSG_NOTE, "\n"); dump_printf (MSG_NOTE, "\n");
} }
else else
{ dump_printf_loc (MSG_NOTE, vect_location,
dump_printf_loc (MSG_NOTE, vect_location, "LOOP EPILOGUE VECTORIZED (MODE=%s)\n",
"LOOP EPILOGUE VECTORIZED (VS="); GET_MODE_NAME (loop_vinfo->vector_mode));
dump_dec (MSG_NOTE, loop_vinfo->vector_size);
dump_printf (MSG_NOTE, ")\n");
}
} }
/* Loops vectorized with a variable factor won't benefit from /* Loops vectorized with a variable factor won't benefit from
......
...@@ -271,7 +271,7 @@ can_duplicate_and_interleave_p (vec_info *vinfo, unsigned int count, ...@@ -271,7 +271,7 @@ can_duplicate_and_interleave_p (vec_info *vinfo, unsigned int count,
{ {
scalar_int_mode int_mode; scalar_int_mode int_mode;
poly_int64 elt_bits = elt_bytes * BITS_PER_UNIT; 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)) && int_mode_for_size (elt_bits, 0).exists (&int_mode))
{ {
tree int_type = build_nonstandard_integer_type tree int_type = build_nonstandard_integer_type
...@@ -475,7 +475,7 @@ again: ...@@ -475,7 +475,7 @@ again:
} }
if ((dt == vect_constant_def if ((dt == vect_constant_def
|| dt == vect_external_def) || dt == vect_external_def)
&& !vinfo->vector_size.is_constant () && !GET_MODE_SIZE (vinfo->vector_mode).is_constant ()
&& (TREE_CODE (type) == BOOLEAN_TYPE && (TREE_CODE (type) == BOOLEAN_TYPE
|| !can_duplicate_and_interleave_p (vinfo, stmts.length (), || !can_duplicate_and_interleave_p (vinfo, stmts.length (),
TYPE_MODE (type)))) TYPE_MODE (type))))
...@@ -2381,8 +2381,11 @@ vect_make_slp_decision (loop_vec_info loop_vinfo) ...@@ -2381,8 +2381,11 @@ vect_make_slp_decision (loop_vec_info loop_vinfo)
FOR_EACH_VEC_ELT (slp_instances, i, instance) FOR_EACH_VEC_ELT (slp_instances, i, instance)
{ {
/* FORNOW: SLP if you can. */ /* FORNOW: SLP if you can. */
/* All unroll factors have the form vinfo->vector_size * X for some /* All unroll factors have the form:
rational X, so they must have a common multiple. */
GET_MODE_SIZE (vinfo->vector_mode) * X
for some rational X, so they must have a common multiple. */
unrolling_factor unrolling_factor
= force_common_multiple (unrolling_factor, = force_common_multiple (unrolling_factor,
SLP_INSTANCE_UNROLLING_FACTOR (instance)); SLP_INSTANCE_UNROLLING_FACTOR (instance));
...@@ -3181,7 +3184,7 @@ vect_slp_bb_region (gimple_stmt_iterator region_begin, ...@@ -3181,7 +3184,7 @@ vect_slp_bb_region (gimple_stmt_iterator region_begin,
vec_info_shared shared; vec_info_shared shared;
poly_uint64 autodetected_vector_size = 0; machine_mode autodetected_vector_mode = VOIDmode;
while (1) while (1)
{ {
bool vectorized = false; bool vectorized = false;
...@@ -3194,7 +3197,7 @@ vect_slp_bb_region (gimple_stmt_iterator region_begin, ...@@ -3194,7 +3197,7 @@ vect_slp_bb_region (gimple_stmt_iterator region_begin,
bb_vinfo->shared->save_datarefs (); bb_vinfo->shared->save_datarefs ();
else else
bb_vinfo->shared->check_datarefs (); 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) if (vect_slp_analyze_bb_1 (bb_vinfo, n_stmts, fatal)
&& dbg_cnt (vect_slp)) && dbg_cnt (vect_slp))
...@@ -3208,7 +3211,7 @@ vect_slp_bb_region (gimple_stmt_iterator region_begin, ...@@ -3208,7 +3211,7 @@ vect_slp_bb_region (gimple_stmt_iterator region_begin,
unsigned HOST_WIDE_INT bytes; unsigned HOST_WIDE_INT bytes;
if (dump_enabled_p ()) 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, dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
"basic block part vectorized using %wu byte " "basic block part vectorized using %wu byte "
"vectors\n", bytes); "vectors\n", bytes);
...@@ -3222,18 +3225,18 @@ vect_slp_bb_region (gimple_stmt_iterator region_begin, ...@@ -3222,18 +3225,18 @@ vect_slp_bb_region (gimple_stmt_iterator region_begin,
} }
if (mode_i == 0) if (mode_i == 0)
autodetected_vector_size = bb_vinfo->vector_size; autodetected_vector_mode = bb_vinfo->vector_mode;
delete bb_vinfo; delete bb_vinfo;
if (mode_i < vector_modes.length () if (mode_i < vector_modes.length ()
&& known_eq (GET_MODE_SIZE (vector_modes[mode_i]), && known_eq (GET_MODE_SIZE (vector_modes[mode_i]),
autodetected_vector_size)) GET_MODE_SIZE (autodetected_vector_mode)))
mode_i += 1; mode_i += 1;
if (vectorized if (vectorized
|| mode_i == vector_modes.length () || 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 /* If vect_slp_analyze_bb_1 signaled that analysis for all
vector sizes will fail do not bother iterating. */ vector sizes will fail do not bother iterating. */
|| fatal) || fatal)
......
...@@ -11226,11 +11226,10 @@ tree ...@@ -11226,11 +11226,10 @@ tree
get_vectype_for_scalar_type (vec_info *vinfo, tree scalar_type) get_vectype_for_scalar_type (vec_info *vinfo, tree scalar_type)
{ {
tree vectype; tree vectype;
vectype = get_vectype_for_scalar_type_and_size (scalar_type, poly_uint64 vector_size = GET_MODE_SIZE (vinfo->vector_mode);
vinfo->vector_size); vectype = get_vectype_for_scalar_type_and_size (scalar_type, vector_size);
if (vectype if (vectype && vinfo->vector_mode == VOIDmode)
&& known_eq (vinfo->vector_size, 0U)) vinfo->vector_mode = TYPE_MODE (vectype);
vinfo->vector_size = GET_MODE_SIZE (TYPE_MODE (vectype));
return vectype; return vectype;
} }
......
...@@ -978,7 +978,7 @@ try_vectorize_loop_1 (hash_table<simduid_to_vf> *&simduid_to_vf_htab, ...@@ -978,7 +978,7 @@ try_vectorize_loop_1 (hash_table<simduid_to_vf> *&simduid_to_vf_htab,
unsigned HOST_WIDE_INT bytes; unsigned HOST_WIDE_INT bytes;
if (dump_enabled_p ()) if (dump_enabled_p ())
{ {
if (loop_vinfo->vector_size.is_constant (&bytes)) if (GET_MODE_SIZE (loop_vinfo->vector_mode).is_constant (&bytes))
dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location, dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
"loop vectorized using %wu byte vectors\n", bytes); "loop vectorized using %wu byte vectors\n", bytes);
else else
......
...@@ -335,9 +335,9 @@ public: ...@@ -335,9 +335,9 @@ public:
/* Cost data used by the target cost model. */ /* Cost data used by the target cost model. */
void *target_cost_data; void *target_cost_data;
/* The vector size for this loop in bytes, or 0 if we haven't picked /* If we've chosen a vector size for this vectorization region,
a size yet. */ this is one mode that has such a size, otherwise it is VOIDmode. */
poly_uint64 vector_size; machine_mode vector_mode;
private: private:
stmt_vec_info new_stmt_vec_info (gimple *stmt); stmt_vec_info new_stmt_vec_info (gimple *stmt);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment