Patchwork Simplify expmed.c:lshift_value

login
register
mail settings
Submitter Richard Sandiford
Date Sept. 9, 2013, 10:31 a.m.
Message ID <8761uagub6.fsf@talisman.default>
Download mbox | patch
Permalink /patch/273549/
State New
Headers show

Comments

Richard Sandiford - Sept. 9, 2013, 10:31 a.m.
expmed.c:lshift_value has:

  val = double_int::from_uhwi (INTVAL (value)).zext (bitsize);
  val = val.llshift (bitpos, HOST_BITS_PER_DOUBLE_INT);

but its only caller has already zero-extended INTVAL (value) from BITSIZE,
so we might as well pass that instead of the (value, bitsize) pair.

This isn't really much of a win on its own, but it makes the associated
wide-int change more obvious.

Tested on x86_64-linux-gnu.  OK to install?

Thanks,
Richard


gcc/
	* expmed.c (lshift_value): Take an unsigned HOST_WIDE_INT instead
	of an rtx/bitpos pair.
	(store_fixed_bit_field): Update accordingly.
Richard Guenther - Sept. 9, 2013, 11:31 a.m.
On Mon, Sep 9, 2013 at 12:31 PM, Richard Sandiford
<rdsandiford@googlemail.com> wrote:
> expmed.c:lshift_value has:
>
>   val = double_int::from_uhwi (INTVAL (value)).zext (bitsize);
>   val = val.llshift (bitpos, HOST_BITS_PER_DOUBLE_INT);
>
> but its only caller has already zero-extended INTVAL (value) from BITSIZE,
> so we might as well pass that instead of the (value, bitsize) pair.
>
> This isn't really much of a win on its own, but it makes the associated
> wide-int change more obvious.
>
> Tested on x86_64-linux-gnu.  OK to install?

Ok.

Thanks,
Richard.

> Thanks,
> Richard
>
>
> gcc/
>         * expmed.c (lshift_value): Take an unsigned HOST_WIDE_INT instead
>         of an rtx/bitpos pair.
>         (store_fixed_bit_field): Update accordingly.
>
> Index: gcc/expmed.c
> ===================================================================
> --- gcc/expmed.c        2013-09-08 11:52:28.995962127 +0100
> +++ gcc/expmed.c        2013-09-08 14:21:49.710092468 +0100
> @@ -56,7 +56,7 @@ static rtx extract_fixed_bit_field (enum
>                                     unsigned HOST_WIDE_INT,
>                                     unsigned HOST_WIDE_INT, rtx, int, bool);
>  static rtx mask_rtx (enum machine_mode, int, int, int);
> -static rtx lshift_value (enum machine_mode, rtx, int, int);
> +static rtx lshift_value (enum machine_mode, unsigned HOST_WIDE_INT, int);
>  static rtx extract_split_bit_field (rtx, unsigned HOST_WIDE_INT,
>                                     unsigned HOST_WIDE_INT, int);
>  static void do_cmp_and_jump (rtx, rtx, enum rtx_code, enum machine_mode, rtx);
> @@ -991,7 +991,7 @@ store_fixed_bit_field (rtx op0, unsigned
>                || (bitsize == HOST_BITS_PER_WIDE_INT && v == -1))
>         all_one = 1;
>
> -      value = lshift_value (mode, value, bitnum, bitsize);
> +      value = lshift_value (mode, v, bitnum);
>      }
>    else
>      {
> @@ -1862,14 +1862,15 @@ mask_rtx (enum machine_mode mode, int bi
>  }
>
>  /* Return a constant integer (CONST_INT or CONST_DOUBLE) rtx with the value
> -   VALUE truncated to BITSIZE bits and then shifted left BITPOS bits.  */
> +   VALUE << BITPOS.  */
>
>  static rtx
> -lshift_value (enum machine_mode mode, rtx value, int bitpos, int bitsize)
> +lshift_value (enum machine_mode mode, unsigned HOST_WIDE_INT value,
> +             int bitpos)
>  {
>    double_int val;
>
> -  val = double_int::from_uhwi (INTVAL (value)).zext (bitsize);
> +  val = double_int::from_uhwi (value);
>    val = val.llshift (bitpos, HOST_BITS_PER_DOUBLE_INT);
>
>    return immed_double_int_const (val, mode);

Patch

Index: gcc/expmed.c
===================================================================
--- gcc/expmed.c	2013-09-08 11:52:28.995962127 +0100
+++ gcc/expmed.c	2013-09-08 14:21:49.710092468 +0100
@@ -56,7 +56,7 @@  static rtx extract_fixed_bit_field (enum
 				    unsigned HOST_WIDE_INT,
 				    unsigned HOST_WIDE_INT, rtx, int, bool);
 static rtx mask_rtx (enum machine_mode, int, int, int);
-static rtx lshift_value (enum machine_mode, rtx, int, int);
+static rtx lshift_value (enum machine_mode, unsigned HOST_WIDE_INT, int);
 static rtx extract_split_bit_field (rtx, unsigned HOST_WIDE_INT,
 				    unsigned HOST_WIDE_INT, int);
 static void do_cmp_and_jump (rtx, rtx, enum rtx_code, enum machine_mode, rtx);
@@ -991,7 +991,7 @@  store_fixed_bit_field (rtx op0, unsigned
 	       || (bitsize == HOST_BITS_PER_WIDE_INT && v == -1))
 	all_one = 1;
 
-      value = lshift_value (mode, value, bitnum, bitsize);
+      value = lshift_value (mode, v, bitnum);
     }
   else
     {
@@ -1862,14 +1862,15 @@  mask_rtx (enum machine_mode mode, int bi
 }
 
 /* Return a constant integer (CONST_INT or CONST_DOUBLE) rtx with the value
-   VALUE truncated to BITSIZE bits and then shifted left BITPOS bits.  */
+   VALUE << BITPOS.  */
 
 static rtx
-lshift_value (enum machine_mode mode, rtx value, int bitpos, int bitsize)
+lshift_value (enum machine_mode mode, unsigned HOST_WIDE_INT value,
+	      int bitpos)
 {
   double_int val;
   
-  val = double_int::from_uhwi (INTVAL (value)).zext (bitsize);
+  val = double_int::from_uhwi (value);
   val = val.llshift (bitpos, HOST_BITS_PER_DOUBLE_INT);
 
   return immed_double_int_const (val, mode);