This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Kill TREE_OVERFLOW during gimplification
- From: "Richard Guenther" <richard dot guenther at gmail dot com>
- To: "Eric Botcazou" <ebotcazou at adacore dot com>
- Cc: "Jakub Jelinek" <jakub at redhat dot com>, gcc-patches at gcc dot gnu dot org
- Date: Wed, 12 Nov 2008 09:27:06 -0600
- Subject: Re: [PATCH] Kill TREE_OVERFLOW during gimplification
- References: <20081016122954.GE30239@tyan-ft48-01.lab.bos.redhat.com> <200811121550.09773.ebotcazou@adacore.com>
On Wed, Nov 12, 2008 at 8:50 AM, Eric Botcazou <ebotcazou@adacore.com> wrote:
>> 2008-10-16 Jakub Jelinek <jakub@redhat.com>
>>
>> * gimplify.c (gimplify_expr): Drop TREE_OVERFLOW from
>> INTEGER_CSTs.
>
> #include <limits.h>
>
> extern void abort (void);
>
> static __attribute__((noinline)) void foo(int a)
> {
> int b = (a - 1) + INT_MIN;
>
> if (b != INT_MIN)
> abort ();
> }
>
> int main (void)
> {
> foo (1);
> return 0;
> }
>
> now aborts at -O2.
>
>
> fold_binary reassociates the RHS expression for 'b' into 'a + 2147483647' with
that re-association is wrong, as it may introduce undefined overflow. The fact
that we set TREE_OVERFLOW on the constant doesn't say that the addition
overflows.
I know this is all nasty - and the correct thing is to finally disentangle the
overflow stuff by separating overflowing and non-overflowing operations. But
for 4.4, Jakub, can you revert the patch?
Thanks,
Richard.