aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@linaro.org>2017-08-30 11:17:29 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2017-08-30 11:17:29 +0000
commit59b5118623ad2e755fbb16b03f2ea122bceebdd2 (patch)
treed8a02d6a9315b50f067bce1643d4b753a588251f /gcc
parent5e4e37bff76a3fbaf4f6e18a343f7c484eeb642e (diff)
downloadgcc-59b5118623ad2e755fbb16b03f2ea122bceebdd2.zip
gcc-59b5118623ad2e755fbb16b03f2ea122bceebdd2.tar.gz
gcc-59b5118623ad2e755fbb16b03f2ea122bceebdd2.tar.bz2
[51/77] Use opt_scalar_int_mode when iterating over integer modes
This patch uses opt_scalar_int_mode rather than machine_mode when iterating over scalar_int_modes, in cases where that helps with future patches. (Using machine_mode is still OK in places that don't really care about the mode being a scalar integer.) 2017-08-30 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * cse.c (cse_insn): Use opt_scalar_int_mode for the mode iterator. * explow.c (hard_function_value): Likewise. * expmed.c (extract_fixed_bit_field_1): Likewise. Move the convert_to_mode call outside the loop. * expr.c (alignment_for_piecewise_move): Use opt_scalar_int_mode for the mode iterator. Require the mode specified by max_pieces to exist. (emit_block_move_via_movmem): Use opt_scalar_int_mode for the mode iterator. (copy_blkmode_to_reg): Likewise. (set_storage_via_setmem): Likewise. * optabs.c (prepare_cmp_insn): Likewise. * rtlanal.c (init_num_sign_bit_copies_in_rep): Likewise. * stor-layout.c (finish_bitfield_representative): Likewise. gcc/fortran/ * trans-types.c (gfc_init_kinds): Use opt_scalar_int_mode for the mode iterator. Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r251503
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog19
-rw-r--r--gcc/cse.c10
-rw-r--r--gcc/explow.c9
-rw-r--r--gcc/expmed.c13
-rw-r--r--gcc/expr.c31
-rw-r--r--gcc/fortran/ChangeLog7
-rw-r--r--gcc/fortran/trans-types.c7
-rw-r--r--gcc/optabs.c4
-rw-r--r--gcc/rtlanal.c12
-rw-r--r--gcc/stor-layout.c15
10 files changed, 79 insertions, 48 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 98fe423..9e03f63 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -2,6 +2,25 @@
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>
+ * cse.c (cse_insn): Use opt_scalar_int_mode for the mode iterator.
+ * explow.c (hard_function_value): Likewise.
+ * expmed.c (extract_fixed_bit_field_1): Likewise. Move the
+ convert_to_mode call outside the loop.
+ * expr.c (alignment_for_piecewise_move): Use opt_scalar_int_mode
+ for the mode iterator. Require the mode specified by max_pieces
+ to exist.
+ (emit_block_move_via_movmem): Use opt_scalar_int_mode for the
+ mode iterator.
+ (copy_blkmode_to_reg): Likewise.
+ (set_storage_via_setmem): Likewise.
+ * optabs.c (prepare_cmp_insn): Likewise.
+ * rtlanal.c (init_num_sign_bit_copies_in_rep): Likewise.
+ * stor-layout.c (finish_bitfield_representative): Likewise.
+
+2017-08-30 Richard Sandiford <richard.sandiford@linaro.org>
+ Alan Hayward <alan.hayward@arm.com>
+ David Sherwood <david.sherwood@arm.com>
+
* rtl.h (subreg_unpromoted_mode, subreg_promoted_mode): New functions.
* expr.c (convert_move): Use them.
(convert_modes): Likewise.
diff --git a/gcc/cse.c b/gcc/cse.c
index d8d730b..34ea3d2 100644
--- a/gcc/cse.c
+++ b/gcc/cse.c
@@ -4885,11 +4885,12 @@ cse_insn (rtx_insn *insn)
&& GET_CODE (src) == AND && CONST_INT_P (XEXP (src, 1))
&& GET_MODE_SIZE (int_mode) < UNITS_PER_WORD)
{
- machine_mode tmode;
+ opt_scalar_int_mode tmode_iter;
rtx new_and = gen_rtx_AND (VOIDmode, NULL_RTX, XEXP (src, 1));
- FOR_EACH_WIDER_MODE (tmode, int_mode)
+ FOR_EACH_WIDER_MODE (tmode_iter, int_mode)
{
+ scalar_int_mode tmode = tmode_iter.require ();
if (GET_MODE_SIZE (tmode) > UNITS_PER_WORD)
break;
@@ -4932,7 +4933,6 @@ cse_insn (rtx_insn *insn)
{
struct rtx_def memory_extend_buf;
rtx memory_extend_rtx = &memory_extend_buf;
- machine_mode tmode;
/* Set what we are trying to extend and the operation it might
have been extended with. */
@@ -4940,10 +4940,12 @@ cse_insn (rtx_insn *insn)
PUT_CODE (memory_extend_rtx, extend_op);
XEXP (memory_extend_rtx, 0) = src;
- FOR_EACH_WIDER_MODE (tmode, int_mode)
+ opt_scalar_int_mode tmode_iter;
+ FOR_EACH_WIDER_MODE (tmode_iter, int_mode)
{
struct table_elt *larger_elt;
+ scalar_int_mode tmode = tmode_iter.require ();
if (GET_MODE_SIZE (tmode) > UNITS_PER_WORD)
break;
diff --git a/gcc/explow.c b/gcc/explow.c
index 72fb682..c5af8ee 100644
--- a/gcc/explow.c
+++ b/gcc/explow.c
@@ -1906,7 +1906,7 @@ hard_function_value (const_tree valtype, const_tree func, const_tree fntype,
&& GET_MODE (val) == BLKmode)
{
unsigned HOST_WIDE_INT bytes = int_size_in_bytes (valtype);
- machine_mode tmpmode;
+ opt_scalar_int_mode tmpmode;
/* int_size_in_bytes can return -1. We don't need a check here
since the value of bytes will then be large enough that no
@@ -1915,14 +1915,11 @@ hard_function_value (const_tree valtype, const_tree func, const_tree fntype,
FOR_EACH_MODE_IN_CLASS (tmpmode, MODE_INT)
{
/* Have we found a large enough mode? */
- if (GET_MODE_SIZE (tmpmode) >= bytes)
+ if (GET_MODE_SIZE (tmpmode.require ()) >= bytes)
break;
}
- /* No suitable mode found. */
- gcc_assert (tmpmode != VOIDmode);
-
- PUT_MODE (val, tmpmode);
+ PUT_MODE (val, tmpmode.require ());
}
return val;
}
diff --git a/gcc/expmed.c b/gcc/expmed.c
index dabde4e..0422ba2 100644
--- a/gcc/expmed.c
+++ b/gcc/expmed.c
@@ -2076,12 +2076,13 @@ extract_fixed_bit_field_1 (machine_mode tmode, rtx op0,
/* Find the narrowest integer mode that contains the field. */
- FOR_EACH_MODE_IN_CLASS (mode, MODE_INT)
- if (GET_MODE_BITSIZE (mode) >= bitsize + bitnum)
- {
- op0 = convert_to_mode (mode, op0, 0);
- break;
- }
+ opt_scalar_int_mode mode_iter;
+ FOR_EACH_MODE_IN_CLASS (mode_iter, MODE_INT)
+ if (GET_MODE_BITSIZE (mode_iter.require ()) >= bitsize + bitnum)
+ break;
+
+ mode = mode_iter.require ();
+ op0 = convert_to_mode (mode, op0, 0);
if (mode != tmode)
target = 0;
diff --git a/gcc/expr.c b/gcc/expr.c
index 7afb4cd..f95a7fe 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -699,18 +699,18 @@ convert_modes (machine_mode mode, machine_mode oldmode, rtx x, int unsignedp)
static unsigned int
alignment_for_piecewise_move (unsigned int max_pieces, unsigned int align)
{
- machine_mode tmode;
+ scalar_int_mode tmode
+ = int_mode_for_size (max_pieces * BITS_PER_UNIT, 1).require ();
- tmode = mode_for_size (max_pieces * BITS_PER_UNIT, MODE_INT, 1);
if (align >= GET_MODE_ALIGNMENT (tmode))
align = GET_MODE_ALIGNMENT (tmode);
else
{
- machine_mode tmode, xmode;
-
- xmode = NARROWEST_INT_MODE;
- FOR_EACH_MODE_IN_CLASS (tmode, MODE_INT)
+ scalar_int_mode xmode = NARROWEST_INT_MODE;
+ opt_scalar_int_mode mode_iter;
+ FOR_EACH_MODE_IN_CLASS (mode_iter, MODE_INT)
{
+ tmode = mode_iter.require ();
if (GET_MODE_SIZE (tmode) > max_pieces
|| SLOW_UNALIGNED_ACCESS (tmode, align))
break;
@@ -1707,7 +1707,6 @@ emit_block_move_via_movmem (rtx x, rtx y, rtx size, unsigned int align,
unsigned HOST_WIDE_INT probable_max_size)
{
int save_volatile_ok = volatile_ok;
- machine_mode mode;
if (expected_align < align)
expected_align = align;
@@ -1726,8 +1725,10 @@ emit_block_move_via_movmem (rtx x, rtx y, rtx size, unsigned int align,
including more than one in the machine description unless
the more limited one has some advantage. */
- FOR_EACH_MODE_IN_CLASS (mode, MODE_INT)
+ opt_scalar_int_mode mode_iter;
+ FOR_EACH_MODE_IN_CLASS (mode_iter, MODE_INT)
{
+ scalar_int_mode mode = mode_iter.require ();
enum insn_code code = direct_optab_handler (movmem_optab, mode);
if (code != CODE_FOR_nothing
@@ -2791,13 +2792,13 @@ copy_blkmode_to_reg (machine_mode mode, tree src)
{
/* Find the smallest integer mode large enough to hold the
entire structure. */
- FOR_EACH_MODE_IN_CLASS (mode, MODE_INT)
- /* Have we found a large enough mode? */
- if (GET_MODE_SIZE (mode) >= bytes)
+ opt_scalar_int_mode mode_iter;
+ FOR_EACH_MODE_IN_CLASS (mode_iter, MODE_INT)
+ if (GET_MODE_SIZE (mode_iter.require ()) >= bytes)
break;
/* A suitable mode should have been found. */
- gcc_assert (mode != VOIDmode);
+ mode = mode_iter.require ();
}
if (GET_MODE_SIZE (mode) < GET_MODE_SIZE (word_mode))
@@ -3035,8 +3036,6 @@ set_storage_via_setmem (rtx object, rtx size, rtx val, unsigned int align,
including more than one in the machine description unless
the more limited one has some advantage. */
- machine_mode mode;
-
if (expected_align < align)
expected_align = align;
if (expected_size != -1)
@@ -3047,8 +3046,10 @@ set_storage_via_setmem (rtx object, rtx size, rtx val, unsigned int align,
expected_size = min_size;
}
- FOR_EACH_MODE_IN_CLASS (mode, MODE_INT)
+ opt_scalar_int_mode mode_iter;
+ FOR_EACH_MODE_IN_CLASS (mode_iter, MODE_INT)
{
+ scalar_int_mode mode = mode_iter.require ();
enum insn_code code = direct_optab_handler (setmem_optab, mode);
if (code != CODE_FOR_nothing
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index c0d684b..7fd40d4 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -2,6 +2,13 @@
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>
+ * trans-types.c (gfc_init_kinds): Use opt_scalar_int_mode for
+ the mode iterator.
+
+2017-08-30 Richard Sandiford <richard.sandiford@linaro.org>
+ Alan Hayward <alan.hayward@arm.com>
+ David Sherwood <david.sherwood@arm.com>
+
* target-memory.c (size_integer): Use SCALAR_INT_TYPE_MODE.
(size_logical): Likewise.
diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c
index 48ba3ac..a3b4c078 100644
--- a/gcc/fortran/trans-types.c
+++ b/gcc/fortran/trans-types.c
@@ -363,15 +363,16 @@ gfc_init_c_interop_kinds (void)
void
gfc_init_kinds (void)
{
- machine_mode mode;
+ opt_scalar_int_mode int_mode_iter;
opt_scalar_float_mode float_mode_iter;
int i_index, r_index, kind;
bool saw_i4 = false, saw_i8 = false;
bool saw_r4 = false, saw_r8 = false, saw_r10 = false, saw_r16 = false;
- for (i_index = 0, mode = MIN_MODE_INT; mode <= MAX_MODE_INT;
- mode = (machine_mode) ((int) mode + 1))
+ i_index = 0;
+ FOR_EACH_MODE_IN_CLASS (int_mode_iter, MODE_INT)
{
+ scalar_int_mode mode = int_mode_iter.require ();
int kind, bitsize;
if (!targetm.scalar_mode_supported_p (mode))
diff --git a/gcc/optabs.c b/gcc/optabs.c
index c54a561..bc93fcf 100644
--- a/gcc/optabs.c
+++ b/gcc/optabs.c
@@ -3800,8 +3800,10 @@ prepare_cmp_insn (rtx x, rtx y, enum rtx_code comparison, rtx size,
/* Try to use a memory block compare insn - either cmpstr
or cmpmem will do. */
- FOR_EACH_MODE_IN_CLASS (cmp_mode, MODE_INT)
+ opt_scalar_int_mode cmp_mode_iter;
+ FOR_EACH_MODE_IN_CLASS (cmp_mode_iter, MODE_INT)
{
+ scalar_int_mode cmp_mode = cmp_mode_iter.require ();
cmp_code = direct_optab_handler (cmpmem_optab, cmp_mode);
if (cmp_code == CODE_FOR_nothing)
cmp_code = direct_optab_handler (cmpstr_optab, cmp_mode);
diff --git a/gcc/rtlanal.c b/gcc/rtlanal.c
index 3066ae2..63009a2 100644
--- a/gcc/rtlanal.c
+++ b/gcc/rtlanal.c
@@ -5660,12 +5660,14 @@ get_condition (rtx_insn *jump, rtx_insn **earliest, int allow_cc_mode,
static void
init_num_sign_bit_copies_in_rep (void)
{
- machine_mode mode, in_mode;
+ opt_scalar_int_mode in_mode_iter;
+ scalar_int_mode mode;
- FOR_EACH_MODE_IN_CLASS (in_mode, MODE_INT)
- FOR_EACH_MODE_UNTIL (mode, in_mode)
+ FOR_EACH_MODE_IN_CLASS (in_mode_iter, MODE_INT)
+ FOR_EACH_MODE_UNTIL (mode, in_mode_iter.require ())
{
- machine_mode i;
+ scalar_int_mode in_mode = in_mode_iter.require ();
+ scalar_int_mode i;
/* Currently, it is assumed that TARGET_MODE_REP_EXTENDED
extends to the next widest mode. */
@@ -5678,7 +5680,7 @@ init_num_sign_bit_copies_in_rep (void)
{
/* This must always exist (for the last iteration it will be
IN_MODE). */
- machine_mode wider = GET_MODE_WIDER_MODE (i).require ();
+ scalar_int_mode wider = GET_MODE_WIDER_MODE (i).require ();
if (targetm.mode_rep_extended (i, wider) == SIGN_EXTEND
/* We can only check sign-bit copies starting from the
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c
index 707c077..ad42c04 100644
--- a/gcc/stor-layout.c
+++ b/gcc/stor-layout.c
@@ -1888,7 +1888,6 @@ static void
finish_bitfield_representative (tree repr, tree field)
{
unsigned HOST_WIDE_INT bitsize, maxbitsize;
- machine_mode mode;
tree nextf, size;
size = size_diffop (DECL_FIELD_OFFSET (field),
@@ -1953,15 +1952,15 @@ finish_bitfield_representative (tree repr, tree field)
gcc_assert (maxbitsize % BITS_PER_UNIT == 0);
/* Find the smallest nice mode to use. */
- FOR_EACH_MODE_IN_CLASS (mode, MODE_INT)
- if (GET_MODE_BITSIZE (mode) >= bitsize)
+ opt_scalar_int_mode mode_iter;
+ FOR_EACH_MODE_IN_CLASS (mode_iter, MODE_INT)
+ if (GET_MODE_BITSIZE (mode_iter.require ()) >= bitsize)
break;
- if (mode != VOIDmode
- && (GET_MODE_BITSIZE (mode) > maxbitsize
- || GET_MODE_BITSIZE (mode) > MAX_FIXED_MODE_SIZE))
- mode = VOIDmode;
- if (mode == VOIDmode)
+ scalar_int_mode mode;
+ if (!mode_iter.exists (&mode)
+ || GET_MODE_BITSIZE (mode) > maxbitsize
+ || GET_MODE_BITSIZE (mode) > MAX_FIXED_MODE_SIZE)
{
/* We really want a BLKmode representative only as a last resort,
considering the member b in