diff options
author | Richard Sandiford <richard.sandiford@linaro.org> | 2017-11-09 15:03:01 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2017-11-09 15:03:01 +0000 |
commit | 9b4473b6c4a706cd5d38a50d10a83c549d676ca3 (patch) | |
tree | 1fae44f84b06409dadb5c1598de1a5106dd9fe18 /gcc/emit-rtl.c | |
parent | 4d93060263ecf25f6324dbc5d07bbd79166cb2a3 (diff) | |
download | gcc-9b4473b6c4a706cd5d38a50d10a83c549d676ca3.zip gcc-9b4473b6c4a706cd5d38a50d10a83c549d676ca3.tar.gz gcc-9b4473b6c4a706cd5d38a50d10a83c549d676ca3.tar.bz2 |
Be stricter about CONST_VECTOR operands
The recent gen_vec_duplicate patches used CONST_VECTOR for all
constants, but the documentation says:
@findex const_vector
@item (const_vector:@var{m} [@var{x0} @var{x1} @dots{}])
Represents a vector constant. The square brackets stand for the vector
containing the constant elements. @var{x0}, @var{x1} and so on are
the @code{const_int}, @code{const_double} or @code{const_fixed} elements.
Both the AArch32 and AArch64 ports relied on the elements having
this form and would ICE if the element was something like a CONST
instead. This showed up as a failure in vect-126.c for both arm-eabi
and aarch64-elf (but not aarch64-linux-gnu, which is what the series
was tested on).
The two obvious options were to redefine CONST_VECTOR to accept all
constants or make gen_vec_duplicate honour the existing documentation.
It looks like other code also assumes that integer CONST_VECTORs contain
CONST_INTs, so the patch does the latter.
I deliberately didn't add an assert to gen_const_vec_duplicate
because it looks like the SPU port *does* expect to be able to create
CONST_VECTORs of symbolic constants.
Also, I think the list above should include const_wide_int for vectors
of TImode and wider.
The new routine takes a mode for consistency with the generators,
and because I think it does make sense to accept all constants for
variable-length:
(const (vec_duplicate ...))
rather than have some rtxes for which we instead use:
(vec_duplicate (const ...))
2017-11-09 Richard Sandiford <richard.sandiford@linaro.org>
gcc/
* doc/rtl.texi (const_vector): Say that elements can be
const_wide_ints too.
* emit-rtl.h (valid_for_const_vec_duplicate_p): Declare.
* emit-rtl.c (valid_for_const_vec_duplicate_p): New function.
(gen_vec_duplicate): Use it instead of CONSTANT_P.
* optabs.c (expand_vector_broadcast): Likewise.
From-SVN: r254586
Diffstat (limited to 'gcc/emit-rtl.c')
-rw-r--r-- | gcc/emit-rtl.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c index ac6fd6a..a076711 100644 --- a/gcc/emit-rtl.c +++ b/gcc/emit-rtl.c @@ -5772,6 +5772,17 @@ init_emit (void) #endif } +/* Return true if X is a valid element for a duplicated vector constant + of the given mode. */ + +bool +valid_for_const_vec_duplicate_p (machine_mode, rtx x) +{ + return (CONST_SCALAR_INT_P (x) + || CONST_DOUBLE_AS_FLOAT_P (x) + || CONST_FIXED_P (x)); +} + /* Like gen_const_vec_duplicate, but ignore const_tiny_rtx. */ static rtx @@ -5807,7 +5818,7 @@ gen_const_vec_duplicate (machine_mode mode, rtx elt) rtx gen_vec_duplicate (machine_mode mode, rtx x) { - if (CONSTANT_P (x)) + if (valid_for_const_vec_duplicate_p (mode, x)) return gen_const_vec_duplicate (mode, x); return gen_rtx_VEC_DUPLICATE (mode, x); } |