[backport from gcc-4.7/trunk r182164, cleanup for PR40154 fix <mikpe@it.uu.se>]

Date: Fri, 09 Dec 2011 09:14:35 -0500
From: Joern Rennecke <amylaar at spamcop dot net>
Subject: Re: RFA: Fix PR middle-end/40154
List-Archive: <http://gcc.gnu.org/ml/gcc-patches/>

Quoting Richard Henderson <rth@redhat.com>:

>> +							 GEN_INT
>> +							   (trunc_int_for_mode
>
> While you're at it, or as a followup, this is combination is gen_int_mode.
> I mis-read the patch the first time and thought you'd done this, but it's
> a pre-existing condition.

I've checked in the attached as a follow-up patch.

gcc/

2011-12-09  Joern Rennecke  <joern.rennecke@embecosm.com>

	* dse.c (get_stored_val, get_call_args): Use gen_int_mode.
	* expmed.c (expand_divmod): Likewise.
	* combine.c (simplify_if_then_else): Likewise.

--- gcc-4.6.2/gcc/combine.c.~1~	2011-07-29 10:35:59.000000000 +0200
+++ gcc-4.6.2/gcc/combine.c	2011-12-10 18:33:25.000000000 +0100
@@ -5949,7 +5949,7 @@ simplify_if_then_else (rtx x)
 	  && exact_log2 (nzb = nonzero_bits (from, GET_MODE (from))) >= 0)
 	{
 	  false_code = EQ;
-	  false_val = GEN_INT (trunc_int_for_mode (nzb, GET_MODE (from)));
+	  false_val = gen_int_mode (nzb, GET_MODE (from));
 	}
       else if (true_code == EQ && true_val == const0_rtx
 	       && (num_sign_bit_copies (from, GET_MODE (from))
--- gcc-4.6.2/gcc/dse.c.~1~	2011-03-26 10:20:34.000000000 +0100
+++ gcc-4.6.2/gcc/dse.c	2011-12-10 18:33:25.000000000 +0100
@@ -1794,7 +1794,7 @@ get_stored_val (store_info_t store_info,
 	      c |= (c << shift);
 	      shift <<= 1;
 	    }
-	  read_reg = GEN_INT (trunc_int_for_mode (c, store_mode));
+	  read_reg = gen_int_mode (c, store_mode);
 	  read_reg = extract_low_bits (read_mode, store_mode, read_reg);
 	}
     }
@@ -2301,7 +2301,7 @@ get_call_args (rtx call_insn, tree fn, r
 	{
 	  if (!tmp || !CONST_INT_P (tmp))
 	    return false;
-	  tmp = GEN_INT (trunc_int_for_mode (INTVAL (tmp), mode));
+	  tmp = gen_int_mode (INTVAL (tmp), mode);
 	}
       if (tmp)
 	args[idx] = tmp;
--- gcc-4.6.2/gcc/expmed.c.~1~	2011-12-10 18:31:04.000000000 +0100
+++ gcc-4.6.2/gcc/expmed.c	2011-12-10 18:33:25.000000000 +0100
@@ -4235,10 +4235,9 @@ expand_divmod (int rem_flag, enum tree_c
 					<< (HOST_BITS_PER_WIDE_INT - 1)))
 			  set_dst_reg_note (insn, REG_EQUAL,
 					    gen_rtx_DIV (compute_mode, op0,
-							 GEN_INT
-							   (trunc_int_for_mode
-							     (abs_d,
-							      compute_mode))),
+							 gen_int_mode
+							   (abs_d,
+							    compute_mode)),
 					    quotient);
 
 			quotient = expand_unop (compute_mode, neg_optab,
