This is the mail archive of the 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

> 2008-10-16  Jakub Jelinek  <>
> 	* gimplify.c (gimplify_expr): Drop TREE_OVERFLOW from

#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 
TREE_OVERFLOW set on the constant.  Then the gimplifier clears it.  Finally 
forwprop propagates the result into 'b != INT_MIN' and fold_comparison 
computes that the result is always true:

  /* Transform comparisons of the form X +- C1 CMP C2 to X CMP C2 +- C1.  */
  if ((TREE_CODE (arg0) == PLUS_EXPR || TREE_CODE (arg0) == MINUS_EXPR)
      && (TREE_CODE (TREE_OPERAND (arg0, 1)) == INTEGER_CST
      && (TREE_CODE (arg1) == INTEGER_CST
	  && !TREE_OVERFLOW (arg1)))

Before the change it would have punted because of TREE_OVERFLOW.

Eric Botcazou

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