Make more use of int_mode_for_mode
authorRichard Sandiford <richard.sandiford@linaro.org>
Tue, 5 Sep 2017 19:56:49 +0000 (19:56 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Tue, 5 Sep 2017 19:56:49 +0000 (19:56 +0000)
This patch converts more places that could use int_mode_for_mode
instead of mode_for_size.  This is in preparation for an upcoming
patch that makes mode_for_size itself return an opt_mode.

The reason for using required () in exp2_immediate_p is that
we go on to do:

    trunc_int_for_mode (..., int_mode)

which would be invalid for (and have failed for) BLKmode.

The reason for using required () in spu_convert_move and
resolve_simple_move is that we go on to use registers of
the returned mode in non-call rtl instructions, which would
be invalid for BLKmode.

2017-09-05  Richard Sandiford  <richard.sandiford@linaro.org>

gcc/
* config/spu/spu.c (exp2_immediate_p): Use int_mode_for_mode.
(spu_convert_move): Likewise.
* lower-subreg.c (resolve_simple_move): Likewise.

From-SVN: r251725

gcc/ChangeLog
gcc/config/spu/spu.c
gcc/lower-subreg.c

index 158b524..58b31d7 100644 (file)
@@ -1,3 +1,9 @@
+2017-09-05  Richard Sandiford  <richard.sandiford@linaro.org>
+
+       * config/spu/spu.c (exp2_immediate_p): Use int_mode_for_mode.
+       (spu_convert_move): Likewise.
+       * lower-subreg.c (resolve_simple_move): Likewise.
+
 2017-09-05  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
        PR target/81833
index d9a0435..e45e302 100644 (file)
@@ -3372,7 +3372,7 @@ arith_immediate_p (rtx op, machine_mode mode,
   constant_to_array (mode, op, arr);
 
   bytes = GET_MODE_UNIT_SIZE (mode);
-  mode = mode_for_size (GET_MODE_UNIT_BITSIZE (mode), MODE_INT, 0);
+  mode = int_mode_for_mode (GET_MODE_INNER (mode)).require ();
 
   /* Check that bytes are repeated. */
   for (i = bytes; i < 16; i += bytes)
@@ -3415,7 +3415,7 @@ exp2_immediate_p (rtx op, machine_mode mode, int low, int high)
   mode = GET_MODE_INNER (mode);
 
   bytes = GET_MODE_SIZE (mode);
-  int_mode = mode_for_size (GET_MODE_BITSIZE (mode), MODE_INT, 0);
+  int_mode = int_mode_for_mode (mode).require ();
 
   /* Check that bytes are repeated. */
   for (i = bytes; i < 16; i += bytes)
@@ -4503,7 +4503,7 @@ static void
 spu_convert_move (rtx dst, rtx src)
 {
   machine_mode mode = GET_MODE (dst);
-  machine_mode int_mode = mode_for_size (GET_MODE_BITSIZE (mode), MODE_INT, 0);
+  machine_mode int_mode = int_mode_for_mode (mode).require ();
   rtx reg;
   gcc_assert (GET_MODE (src) == TImode);
   reg = int_mode != mode ? gen_reg_rtx (int_mode) : dst;
index e93dbd6..43b6cd0 100644 (file)
@@ -956,11 +956,7 @@ resolve_simple_move (rtx set, rtx_insn *insn)
       if (real_dest == NULL_RTX)
        real_dest = dest;
       if (!SCALAR_INT_MODE_P (dest_mode))
-       {
-         dest_mode = mode_for_size (GET_MODE_SIZE (dest_mode) * BITS_PER_UNIT,
-                                    MODE_INT, 0);
-         gcc_assert (dest_mode != BLKmode);
-       }
+       dest_mode = int_mode_for_mode (dest_mode).require ();
       dest = gen_reg_rtx (dest_mode);
       if (REG_P (real_dest))
        REG_ATTRS (dest) = REG_ATTRS (real_dest);