This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Kill TREE_OVERFLOW during gimplification


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]