diff options
author | Richard Sandiford <richard.sandiford@linaro.org> | 2017-08-30 11:19:39 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2017-08-30 11:19:39 +0000 |
commit | db61b7f923b769142156eab047c94b04bb7adaae (patch) | |
tree | 522f1a6eed83a6d3571b7d5746f0fbeb9c488141 /gcc/dwarf2out.c | |
parent | b397965cae46d88d4c274fb2ecdde9a4714a4e6a (diff) | |
download | gcc-db61b7f923b769142156eab047c94b04bb7adaae.zip gcc-db61b7f923b769142156eab047c94b04bb7adaae.tar.gz gcc-db61b7f923b769142156eab047c94b04bb7adaae.tar.bz2 |
[66/77] Use scalar_mode for constant integers
This patch treats the mode associated with an integer constant as a
scalar_mode. We can't use the more natural-sounding scalar_int_mode
because we also use (const_int 0) for bounds-checking modes. (It might
be worth adding a bounds-specific code instead, but that's for another
day.)
This exposes a latent bug in simplify_immed_subreg, which for
vectors of CONST_WIDE_INTs would pass the vector mode rather than
the element mode to rtx_mode_t.
I think the:
/* We can get a 0 for an error mark. */
|| GET_MODE_CLASS (mode) == MODE_VECTOR_INT
|| GET_MODE_CLASS (mode) == MODE_VECTOR_FLOAT
in immed_double_const is dead. trunc_int_mode (via gen_int_mode)
would go on to ICE if the mode fitted in a HWI, and surely plenty
of other code would be confused to see a const_int be interpreted
as a vector. We should instead be using CONST0_RTX (mode) if we
need a safe constant for a particular mode.
We didn't try to make these functions take scalar_mode arguments
because in many cases that would be too invasive at this stage.
Maybe it would become feasible in future. Also, the long-term
direction should probably be to add modes to constant integers
rather than have then as VOIDmode odd-ones-out. That would remove
the need for rtx_mode_t and thus remove the question whether they
should use scalar_int_mode, scalar_mode or machine_mode.
The patch also uses scalar_mode for the CONST_DOUBLE handling
in loc_descriptor. In that case the mode can legitimately be
either floating-point or integral.
2017-08-30 Richard Sandiford <richard.sandiford@linaro.org>
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>
gcc/
* emit-rtl.c (immed_double_const): Use is_a <scalar_mode> instead
of separate mode class checks. Do not allow vector modes here.
(immed_wide_int_const): Use as_a <scalar_mode>.
* explow.c (trunc_int_for_mode): Likewise.
* rtl.h (wi::int_traits<rtx_mode_t>::get_precision): Likewise.
(wi::shwi): Likewise.
(wi::min_value): Likewise.
(wi::max_value): Likewise.
* dwarf2out.c (loc_descriptor): Likewise.
* simplify-rtx.c (simplify_immed_subreg): Fix rtx_mode_t argument
for CONST_WIDE_INT.
Co-Authored-By: Alan Hayward <alan.hayward@arm.com>
Co-Authored-By: David Sherwood <david.sherwood@arm.com>
From-SVN: r251517
Diffstat (limited to 'gcc/dwarf2out.c')
-rw-r--r-- | gcc/dwarf2out.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index f857a27..42da36c 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -15863,10 +15863,11 @@ loc_descriptor (rtx rtl, machine_mode mode, or a floating-point constant. A CONST_DOUBLE is used whenever the constant requires more than one word in order to be adequately represented. We output CONST_DOUBLEs as blocks. */ + scalar_mode smode = as_a <scalar_mode> (mode); loc_result = new_loc_descr (DW_OP_implicit_value, - GET_MODE_SIZE (mode), 0); + GET_MODE_SIZE (smode), 0); #if TARGET_SUPPORTS_WIDE_INT == 0 - if (!SCALAR_FLOAT_MODE_P (mode)) + if (!SCALAR_FLOAT_MODE_P (smode)) { loc_result->dw_loc_oprnd2.val_class = dw_val_class_const_double; loc_result->dw_loc_oprnd2.v.val_double @@ -15875,7 +15876,7 @@ loc_descriptor (rtx rtl, machine_mode mode, else #endif { - unsigned int length = GET_MODE_SIZE (mode); + unsigned int length = GET_MODE_SIZE (smode); unsigned char *array = ggc_vec_alloc<unsigned char> (length); insert_float (rtl, array); |