This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH]Fix computation of offset in ivopt
- From: Bernd Schmidt <bernds at codesourcery dot com>
- To: Richard Biener <richard dot guenther at gmail dot com>
- Cc: bin.cheng <bin dot cheng at arm dot com>, Bin.Cheng <amker dot cheng at gmail dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 18 Oct 2013 14:26:14 +0200
- Subject: Re: [PATCH]Fix computation of offset in ivopt
- Authentication-results: sourceware.org; auth=none
- References: <001501ceb906$56da1c00$048e5400$ at arm dot com> <CAFiYyc0WO3M8x-0eyN4xpami9yemcX0cVy=awfOFYYmeo+OSyg at mail dot gmail dot com> <002701cebb3f$6fcd6ab0$4f684010$ at arm dot com> <CAFiYyc0M_7mSxED5YK7WYy+7mxd3Axdzdy=smnSEQj2iPx9m3A at mail dot gmail dot com> <002901cebd9f$5f7cb0a0$1e7611e0$ at arm dot com> <CAFiYyc1J1FBhsgsj9hgcMWg4o8M7soY3h4CGQWa+FyVqrEv_eQ at mail dot gmail dot com> <CAHFci295kKk7CXiEPfEGiPDy+ekew7TgEWygr-_prYbV9Sscow at mail dot gmail dot com> <CAFiYyc1r030B6H_XLt4iiLSabiCxWqN34BmQrcX+ZCfTtpMxpA at mail dot gmail dot com> <002e01cecafd$03809c60$0a81d520$ at arm dot com> <CAFiYyc34mD6Rx+JUmv8d=1UH3_eqgqoeLE7wE-qBX7XAye7+ow at mail dot gmail dot com> <52612370 dot 2010304 at codesourcery dot com> <CAFiYyc33thdkNYCrL3=rhDpf-qjOF2MZbnnabgoKoEU1naNJkQ at mail dot gmail dot com>
On 10/18/2013 02:10 PM, Richard Biener wrote:
> On Fri, Oct 18, 2013 at 2:02 PM, Bernd Schmidt <bernds@codesourcery.com> wrote:
>> On 10/18/2013 01:18 PM, Richard Biener wrote:
>>
>>> Index: gcc/fold-const.c
>>> ===================================================================
>>> --- gcc/fold-const.c (revision 203267)
>>> +++ gcc/fold-const.c (working copy)
>>> @@ -7270,8 +7270,8 @@ fold_plusminus_mult_expr (location_t loc, enum tre
>>> HOST_WIDE_INT int01, int11, tmp;
>>> bool swap = false;
>>> tree maybe_same;
>>> - int01 = TREE_INT_CST_LOW (arg01);
>>> - int11 = TREE_INT_CST_LOW (arg11);
>>> + int01 = int_cst_value (arg01);
>>> + int11 = int_cst_value (arg11);
>>>
>>> this is not correct - it will mishandle all large unsigned numbers.
>>>
>>> The real issue is that we rely on twos-complement arithmetic to work
>>> when operating on pointer offsets (because we convert them all to
>>> unsigned sizetype). That makes interpreting the offsets or expressions
>>> that compute offsets hard (or impossible in some cases), as you can
>>> see from the issues in IVOPTs.
>>
>> I still have patches to keep pointer types in ivopts (using a new
>> POINTER_PLUSV_EXPR). Would that help in this case? Last time I posted
>> them they met an unenthusiastic reception so I've never bothered to
>> repost them.
>
> Can you point me to that patch? Or shortly elaborate on "keep pointer types
> in ivopts"? I think this issue is about decomposing offset computations into
> a constant and a variable part, which after foldings messed up the unsigned
> computation can result in "odd" constant offset parts. So it's rather
> because the offset operand of POINTER_PLUS_EXPR is fixed as
> sizetype.
Okay, my patch doesn't address that part, it only ensures the pointer
base values are kept and arithmetic on them is done using POINTER_PLUS.
The original patch was here.
http://gcc.gnu.org/ml/gcc-patches/2012-03/msg01104.html
Bernd