diff mbox series

[1/9] Make more use of int_mode_for_mode

Message ID 87pob6iu26.fsf@linaro.org
State New
Headers show
Series Make more use of opt_mode | expand

Commit Message

Richard Sandiford Sept. 4, 2017, 11:26 a.m. UTC
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-04  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.

Comments

Richard Biener Sept. 5, 2017, 11:22 a.m. UTC | #1
On Mon, Sep 4, 2017 at 1:26 PM, Richard Sandiford
<richard.sandiford@linaro.org> wrote:
> 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.


Ok.

Richard.

> 2017-09-04  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.

>

> Index: gcc/config/spu/spu.c

> ===================================================================

> --- gcc/config/spu/spu.c        2017-09-04 11:50:24.563372530 +0100

> +++ gcc/config/spu/spu.c        2017-09-04 12:18:41.572976650 +0100

> @@ -3372,7 +3372,7 @@ arith_immediate_p (rtx op, machine_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 m

>    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 @@ spu_expand_mov (rtx * ops, machine_mode

>  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: gcc/lower-subreg.c

> ===================================================================

> --- gcc/lower-subreg.c  2017-09-04 11:50:08.544543511 +0100

> +++ gcc/lower-subreg.c  2017-09-04 12:18:41.572976650 +0100

> @@ -956,11 +956,7 @@ resolve_simple_move (rtx set, rtx_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);
diff mbox series

Patch

Index: gcc/config/spu/spu.c
===================================================================
--- gcc/config/spu/spu.c	2017-09-04 11:50:24.563372530 +0100
+++ gcc/config/spu/spu.c	2017-09-04 12:18:41.572976650 +0100
@@ -3372,7 +3372,7 @@  arith_immediate_p (rtx op, machine_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 m
   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 @@  spu_expand_mov (rtx * ops, machine_mode
 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: gcc/lower-subreg.c
===================================================================
--- gcc/lower-subreg.c	2017-09-04 11:50:08.544543511 +0100
+++ gcc/lower-subreg.c	2017-09-04 12:18:41.572976650 +0100
@@ -956,11 +956,7 @@  resolve_simple_move (rtx set, rtx_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);