diff mbox

[wide-int] A few assorted simplifications

Message ID 87a9hdhoxt.fsf@talisman.default
State New
Headers show

Commit Message

Richard Sandiford Nov. 9, 2013, 10:03 a.m. UTC
These changes don't have much in common except being simplifications.
Note that "len == 0" isn't possible now that we've eliminated the
0-precision case.  "val = val" should be redundant.

Tested on powerpc64-linux-gnu and by rerunning the assembly comparison.
OK to install?

Richard

Comments

Mike Stump Nov. 9, 2013, 4:26 p.m. UTC | #1
On Nov 9, 2013, at 2:03 AM, Richard Sandiford <rdsandiford@googlemail.com> wrote:
> These changes don't have much in common except being simplifications.
> Note that "len == 0" isn't possible now that we've eliminated the
> 0-precision case.  "val = val" should be redundant.
> 
> OK to install?

Ok.
diff mbox

Patch

Index: gcc/expmed.c
===================================================================
--- gcc/expmed.c	2013-11-09 09:39:17.841740772 +0000
+++ gcc/expmed.c	2013-11-09 09:39:27.370805176 +0000
@@ -3652,7 +3652,7 @@  expand_smod_pow2 (enum machine_mode mode
      modulus.  By including the signbit in the operation, many targets
      can avoid an explicit compare operation in the following comparison
      against zero.  */
-  wide_int mask = wi::mask (logd, false, GET_MODE_PRECISION (mode));
+  wide_int mask = wi::mask (logd, false, prec);
   mask = wi::set_bit (mask, prec - 1);
 
   temp = expand_binop (mode, and_optab, op0,
@@ -3667,7 +3667,7 @@  expand_smod_pow2 (enum machine_mode mode
   temp = expand_binop (mode, sub_optab, result, const1_rtx, result,
 		       0, OPTAB_LIB_WIDEN);
 
-  mask = wi::mask (logd, true, GET_MODE_PRECISION (mode));
+  mask = wi::mask (logd, true, prec);
   temp = expand_binop (mode, ior_optab, temp,
 		       immed_wide_int_const (mask, mode),
 		       result, 1, OPTAB_LIB_WIDEN);
Index: gcc/fold-const.c
===================================================================
--- gcc/fold-const.c	2013-11-09 09:39:26.729800844 +0000
+++ gcc/fold-const.c	2013-11-09 09:39:27.373805197 +0000
@@ -7175,8 +7175,7 @@  fold_plusminus_mult_expr (location_t loc
       arg10 = build_one_cst (type);
       /* As we canonicalize A - 2 to A + -2 get rid of that sign for
 	 the purpose of this canonicalization.  */
-      if (TYPE_SIGN (TREE_TYPE (arg1)) == SIGNED
-	  && wi::neg_p (arg1)
+      if (wi::neg_p (arg1, TYPE_SIGN (TREE_TYPE (arg1)))
 	  && negate_expr_p (arg1)
 	  && code == PLUS_EXPR)
 	{
Index: gcc/real.c
===================================================================
--- gcc/real.c	2013-11-09 09:39:26.732800864 +0000
+++ gcc/real.c	2013-11-09 09:39:27.373805197 +0000
@@ -1422,7 +1422,7 @@  real_to_integer (const REAL_VALUE_TYPE *
 
       words = (precision + HOST_BITS_PER_WIDE_INT - 1) / HOST_BITS_PER_WIDE_INT;
 
-      for (int i = 0; i < 2 * MAX_BITSIZE_MODE_ANY_INT / HOST_BITS_PER_WIDE_INT; i++)
+      for (unsigned int i = 0; i < ARRAY_SIZE (val); i++)
 	val[i] = 0;
 
 #if (HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG)
@@ -2205,16 +2205,11 @@  real_from_integer (REAL_VALUE_TYPE *r, e
       r->cl = rvc_normal;
       r->sign = wi::neg_p (val_in, sgn);
 
-      if (len == 0)
-	len = 1;
-
       /* We have to ensure we can negate the largest negative number.  */
       wide_int val = wide_int::from (val_in, maxbitlen, sgn);
 
       if (r->sign)
 	val = -val;
-      else
-	val = val;
       
       /* Ensure a multiple of HOST_BITS_PER_WIDE_INT, ceiling, as elt
 	 won't work with precisions that are not a multiple of