...for consistency with mode_for_vector.
2017-09-05 Richard Sandiford <richard.sandiford@linaro.org>
gcc/
* target.def (get_mask_mode): Change return type to opt_mode.
Expand commentary.
* doc/tm.texi: Regenerate.
* targhooks.h (default_get_mask_mode): Return an opt_mode.
* targhooks.c (default_get_mask_mode): Likewise.
* config/i386/i386.c (ix86_get_mask_mode): Likewise.
* optabs-query.c (can_vec_mask_load_store_p): Update use of
targetm.get_mask_mode.
* tree.c (build_truth_vector_type): Likewise.
From-SVN: r251731
+2017-09-05 Richard Sandiford <richard.sandiford@linaro.org>
+
+ * target.def (get_mask_mode): Change return type to opt_mode.
+ Expand commentary.
+ * doc/tm.texi: Regenerate.
+ * targhooks.h (default_get_mask_mode): Return an opt_mode.
+ * targhooks.c (default_get_mask_mode): Likewise.
+ * config/i386/i386.c (ix86_get_mask_mode): Likewise.
+ * optabs-query.c (can_vec_mask_load_store_p): Update use of
+ targetm.get_mask_mode.
+ * tree.c (build_truth_vector_type): Likewise.
+
2017-09-05 Richard Sandiford <richard.sandiford@linaro.org>
* machmode.h (mode_for_vector): Return an opt_mode.
/* Implemenation of targetm.vectorize.get_mask_mode. */
-static machine_mode
+static opt_machine_mode
ix86_get_mask_mode (unsigned nunits, unsigned vector_size)
{
unsigned elem_size = vector_size / nunits;
gcc_assert (elem_size * nunits == vector_size);
- return mode_for_vector (elem_mode, nunits).else_blk ();
+ return mode_for_vector (elem_mode, nunits);
}
\f
The default is zero which means to not iterate over other vector sizes.
@end deftypefn
-@deftypefn {Target Hook} machine_mode TARGET_VECTORIZE_GET_MASK_MODE (unsigned @var{nunits}, unsigned @var{length})
-This hook returns mode to be used for a mask to be used for a vector
-of specified @var{length} with @var{nunits} elements. By default an integer
-vector mode of a proper size is returned.
+@deftypefn {Target Hook} opt_machine_mode TARGET_VECTORIZE_GET_MASK_MODE (unsigned @var{nunits}, unsigned @var{length})
+A vector mask is a value that holds one boolean result for every element
+in a vector. This hook returns the machine mode that should be used to
+represent such a mask when the vector in question is @var{length} bytes
+long and contains @var{nunits} elements. The hook returns an empty
+@code{opt_machine_mode} if no such mode exists.
+
+The default implementation returns the mode of an integer vector that
+is @var{length} bytes long and that contains @var{nunits} elements,
+if such a mode exists.
@end deftypefn
@deftypefn {Target Hook} {void *} TARGET_VECTORIZE_INIT_COST (struct loop *@var{loop_info})
if (!VECTOR_MODE_P (vmode))
return false;
- mask_mode = targetm.vectorize.get_mask_mode (GET_MODE_NUNITS (vmode),
- GET_MODE_SIZE (vmode));
- if (mask_mode == VOIDmode)
- return false;
-
- if (convert_optab_handler (op, vmode, mask_mode) != CODE_FOR_nothing)
+ if ((targetm.vectorize.get_mask_mode
+ (GET_MODE_NUNITS (vmode), GET_MODE_SIZE (vmode)).exists (&mask_mode))
+ && convert_optab_handler (op, vmode, mask_mode) != CODE_FOR_nothing)
return true;
vector_sizes = targetm.vectorize.autovectorize_vector_sizes ();
continue;
unsigned int nunits = cur / GET_MODE_SIZE (smode);
if (mode_for_vector (smode, nunits).exists (&vmode)
- && VECTOR_MODE_P (vmode))
- {
- mask_mode = targetm.vectorize.get_mask_mode (nunits, cur);
- if (convert_optab_handler (op, vmode, mask_mode) != CODE_FOR_nothing)
- return true;
- }
+ && VECTOR_MODE_P (vmode)
+ && targetm.vectorize.get_mask_mode (nunits, cur).exists (&mask_mode)
+ && convert_optab_handler (op, vmode, mask_mode) != CODE_FOR_nothing)
+ return true;
}
return false;
}
/* Function to get a target mode for a vector mask. */
DEFHOOK
(get_mask_mode,
- "This hook returns mode to be used for a mask to be used for a vector\n\
-of specified @var{length} with @var{nunits} elements. By default an integer\n\
-vector mode of a proper size is returned.",
- machine_mode,
+ "A vector mask is a value that holds one boolean result for every element\n\
+in a vector. This hook returns the machine mode that should be used to\n\
+represent such a mask when the vector in question is @var{length} bytes\n\
+long and contains @var{nunits} elements. The hook returns an empty\n\
+@code{opt_machine_mode} if no such mode exists.\n\
+\n\
+The default implementation returns the mode of an integer vector that\n\
+is @var{length} bytes long and that contains @var{nunits} elements,\n\
+if such a mode exists.",
+ opt_machine_mode,
(unsigned nunits, unsigned length),
default_get_mask_mode)
/* By defaults a vector of integers is used as a mask. */
-machine_mode
+opt_machine_mode
default_get_mask_mode (unsigned nunits, unsigned vector_size)
{
unsigned elem_size = vector_size / nunits;
gcc_assert (elem_size * nunits == vector_size);
- if (!mode_for_vector (elem_mode, nunits).exists (&vector_mode)
- || !VECTOR_MODE_P (vector_mode)
- || !targetm.vector_mode_supported_p (vector_mode))
- vector_mode = BLKmode;
+ if (mode_for_vector (elem_mode, nunits).exists (&vector_mode)
+ && VECTOR_MODE_P (vector_mode)
+ && targetm.vector_mode_supported_p (vector_mode))
+ return vector_mode;
- return vector_mode;
+ return opt_machine_mode ();
}
/* By default, the cost model accumulates three separate costs (prologue,
int, bool);
extern machine_mode default_preferred_simd_mode (scalar_mode mode);
extern unsigned int default_autovectorize_vector_sizes (void);
-extern machine_mode default_get_mask_mode (unsigned, unsigned);
+extern opt_machine_mode default_get_mask_mode (unsigned, unsigned);
extern void *default_init_cost (struct loop *);
extern unsigned default_add_stmt_cost (void *, int, enum vect_cost_for_stmt,
struct _stmt_vec_info *, int,
tree
build_truth_vector_type (unsigned nunits, unsigned vector_size)
{
- machine_mode mask_mode = targetm.vectorize.get_mask_mode (nunits,
- vector_size);
-
- gcc_assert (mask_mode != VOIDmode);
+ machine_mode mask_mode
+ = targetm.vectorize.get_mask_mode (nunits, vector_size).else_blk ();
unsigned HOST_WIDE_INT vsize;
if (mask_mode == BLKmode)