This is the mail archive of the
mailing list for the GCC project.
Re: [wide-int] Do not treat rtxes as sign-extended
- From: Kenneth Zadeck <zadeck at naturalbridge dot com>
- To: gcc-patches at gcc dot gnu dot org, mikestump at comcast dot net, rdsandiford at googlemail dot com
- Date: Sat, 02 Nov 2013 09:45:56 -0400
- Subject: Re: [wide-int] Do not treat rtxes as sign-extended
- Authentication-results: sourceware.org; auth=none
- References: <874n7vkse3 dot fsf at talisman dot default>
On 11/02/2013 06:30 AM, Richard Sandiford wrote:
do we have to throw away the baby with the bath water here? I guess
what you are saying is that it is worse to have is_sign_extended be a
variable that is almost always true than to be a hard false.
Bah. After all that effort, it turns out that -- by design --
there is one special case where CONST_INTs are not sign-extended.
Nonzero/true BImode integers are stored as STORE_FLAG_VALUE,
which can be 1 rather than -1. So (const_int 1) can be a valid
BImode integer -- and consequently (const_int -1) can be wrong --
even though BImode only has 1 bit.
It might be nice to change that, but for wide-int I think we should
just treat rtxes like trees for now.
Tested on powerpc64-linux-gnu and x86_64-linux-gnu. It fixes some ICEs
seen on bfin-elf. OK to install?
also we could preserve the test and make it not apply to bimode.
--- gcc/rtl.h (revision 204311)
+++ gcc/rtl.h (working copy)
@@ -1408,7 +1408,9 @@
static const enum precision_type precision_type = VAR_PRECISION;
static const bool host_dependent_precision = false;
- static const bool is_sign_extended = true;
+ /* This ought to be true, except for the special case that BImode
+ is canonicalized to STORE_FLAG_VALUE, which might be 1. */
+ static const bool is_sign_extended = false;
static unsigned int get_precision (const rtx_mode_t &);
static wi::storage_ref decompose (HOST_WIDE_INT *, unsigned int,
const rtx_mode_t &);
@@ -1430,10 +1432,6 @@
switch (GET_CODE (x.first))
- if (precision < HOST_BITS_PER_WIDE_INT)
- gcc_checking_assert (INTVAL (x.first)
- == sext_hwi (INTVAL (x.first), precision));
return wi::storage_ref (&INTVAL (x.first), 1, precision);