This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: suspect code in fold-const.c
- From: Eric Botcazou <ebotcazou at adacore dot com>
- To: Kenneth Zadeck <zadeck at naturalbridge dot com>
- Cc: Richard Sandiford <rdsandiford at googlemail dot com>, gcc at gcc dot gnu dot org, Richard Biener <rguenther at suse dot de>
- Date: Fri, 15 Nov 2013 10:07:38 +0100
- Subject: Re: suspect code in fold-const.c
- Authentication-results: sourceware.org; auth=none
- References: <5284F74F dot 4050600 at naturalbridge dot com>
> this code from fold-const.c starts on line 13811.
>
> else if (TREE_INT_CST_HIGH (arg1) == signed_max_hi
> && TREE_INT_CST_LOW (arg1) == signed_max_lo
> && TYPE_UNSIGNED (arg1_type)
> /* We will flip the signedness of the comparison operator
> associated with the mode of arg1, so the sign bit is
> specified by this mode. Check that arg1 is the signed
> max associated with this sign bit. */
> && width == GET_MODE_BITSIZE (TYPE_MODE (arg1_type))
> /* signed_type does not work on pointer types. */
> && INTEGRAL_TYPE_P (arg1_type))
with width defined as:
unsigned int width = TYPE_PRECISION (arg1_type);
> it seems that the check on bitsize should really be a check on the
> precision of the variable. If this seems right, i will correct this on
> the trunk and make the appropriate changes to the wide-int branch.
Do you mean
&& width == GET_MODE_PRECISION (TYPE_MODE (arg1_type))
instead? If so, that would probably make sense, but there are a few other
places with the same TYPE_PRECISION/GET_MODE_BITSIZE check, in particular the
very similar transformation done in fold_single_bit_test_into_sign_test.
--
Eric Botcazou