public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH/RFC] Death to TREE_CONSTANT_OVERFLOW
@ 2007-01-10  3:06 Roger Sayle
  2007-01-10  9:22 ` Richard Guenther
  0 siblings, 1 reply; 4+ messages in thread
From: Roger Sayle @ 2007-01-10  3:06 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 4597 bytes --]


The following pair of patches perform the major steps in obsoleting the
macro TREE_CONSTANT_OVERFLOW and its need for a bit in expression tree
nodes.  Currently, GCC maintains two "overflow" bits on each constant
expression tree node, TREE_OVERFLOW and TREE_CONSTANT_OVERFLOW.  The
difference in semantics between these two fields has historically been
used to track whether or not a diagnostic has been emitted by the C/C++
front-end.  After several years of effort to unify these fields, and with
the recent constant overflow warning patches by Manuel, we've now reached
the point that these two fields are completely synonymous, and there's no
longer any reason for the C front-end to maintain this aspect of state in
the middle-end's tree representation.  Indeed few middle-end contributors
fully understood the difference between TREE_CONSTANT_OVERFLOW and
TREE_OVERFLOW and examination of the source shows they've been used and
misused interchangeably.

Attached below are two patches, the first is a simple tweak to tree.h that
makes TREE_CONSTANT_OVERFLOW a synonym for TREE_OVERFLOW.  With this
change alone, i686-pc-linux-gnu can be fully bootstrapped, all default
languages including Ada, and regression tested with a top-level "make -k
check" with no new failures.  This demonstrates/confirms that the
distinction is no longer necessary, and serves as a "transition state"
whilst the tree is transitioned such that all uses of
TREE_CONSTANT_OVERFLOW are replaced with TREE_OVERFLOW.  Once this
transition is complete, the definition of TREE_CONSTANT_OVERFLOW can be
completely removed from tree.h.

To start the ball rolling, the second patch below does precisely this for
all uses of TREE_CONSTANT_OVERFLOW in the middle-end (the main users being
fold-const.c and builtins.c).  This patch has also been bootstrapped and
regression tested on i686-pc-linux-gnu, all languages including Ada, on
top of the first tree.h patch with no new failures.

Rather than commit both patches under my own authority without warning, I
thought it far more polite to propose these changes here to give folks a
"heads up", and the opportunity to complain or plan for this transition.
For the time being TREE_CONSTANT_OVERFLOW will still exist, so pending
branch merges and tree-ssa optimization passes that refer to it shouldn't
have a problem.  But ultimately, once all the front-ends have been weaned
this macro will disappear (possibly even poisoned).

Thoughts, comments or objections?  If there isn't a outcry, I propose to
commit both patches to mainline in a day or two.  If the C/C++ front-end
maintainers notice a problem on Plum-Hall or other testsuite not covered
by the dejagnu testsuite I'm happy to hold-off on this patch, until that
issue is resolved.  However, I don't expect a problem, as recent
improvements to our overflow diagnostics have made them better than
they've ever been.

Ok?


2007-01-09  Roger Sayle  <roger@eyesopen.com>

        * tree.h (TREE_CONSTANT_OVERFLOW): Obsolete.  For the time being,
        treat TREE_CONSTANT_OVERFLOW as a synonym of TREE_OVERFLOW.


2007-01-09  Roger Sayle  <roger@eyesopen.com>

        * builtins.c (expand_builtin_pow, expand_builtin_powi,
        fold_builtin_cabs, fold_builtin_sqrt, fold_builtin_trunc,
        fold_builtin_floor, fold_builtin_ceil, fold_builtin_round,
        fold_builtin_int_int_roundingfn, fold_builtin_bitop,
        fold_builtin_bswap, real_constp, fold_builtin_pow,
        fold_builtin_powi, fold_builtin_signbit, fold_builtin_copysign,
        fold_builtin_object_size, do_mpfr_arg1, do_mpfr_arg2,
        do_mpfr_arg3, do_mpfr_sincos): Replace uses of the macro
        TREE_CONSTANT_OVERFLOW with TREE_OVERFLOW.
        * convert.c (convert_to_pointer): Likewise.
        * expr.c (highest_pow2_factor, expand_expr_real_1): Likewise.
        * fold-const.c (force_fit_type, fold_negate_expr, int_const_binop,
        const_binop, fold_convert_const_int_from_int,
        fold_convert_const_int_from_real,
        fold_convert_const_real_from_real, sign_bit_p,
        optimize_minmax_comparison, extract_muldiv_1, fold_div_compare,
        fold_sign_changed_comparison, fold_unary, fold_comparison,
        fold_binary, multiple_of_p, tree_Expr_non_zero_p,
        fold_negate_const, fold_abs_const, fold_not_const): Likewise.
        * print-tree.c (print_node_brief, print_node): Likewise.
        * stor-layout.c (place_field, layout_type): Likewise.
        * tree-chrec.c (keep_cast): Likewise.
        * tree.c (build_vector, build_real, build_real_from_int_cst,
        build_complex): Likewise.

[-- Attachment #2: patchc.txt --]
[-- Type: text/plain, Size: 2210 bytes --]

Index: tree.h
===================================================================
*** tree.h	(revision 120520)
--- tree.h	(working copy)
*************** struct gimple_stmt GTY(())
*** 426,433 ****
             VAR_DECL, FUNCTION_DECL, CONSTRUCTOR, ADDR_EXPR
         BINFO_VIRTUAL_P in
             TREE_BINFO
-        TREE_CONSTANT_OVERFLOW in
-            INTEGER_CST, REAL_CST, COMPLEX_CST, VECTOR_CST
         TREE_SYMBOL_REFERENCED in
             IDENTIFIER_NODE
         CLEANUP_EH_ONLY in
--- 426,431 ----
*************** extern void omp_clause_range_check_faile
*** 1133,1144 ****
     emitted.  */
  #define TREE_NO_WARNING(NODE) ((NODE)->base.nowarning_flag)
  
- /* In an INTEGER_CST, REAL_CST, COMPLEX_CST, or VECTOR_CST this means
-    there was an overflow in folding.  This is distinct from
-    TREE_OVERFLOW because ANSI C requires a diagnostic when overflows
-    occur in constant expressions.  */
- #define TREE_CONSTANT_OVERFLOW(NODE) (CST_CHECK (NODE)->base.static_flag)
- 
  /* In an IDENTIFIER_NODE, this means that assemble_name was called with
     this string as an argument.  */
  #define TREE_SYMBOL_REFERENCED(NODE) \
--- 1131,1136 ----
*************** extern void omp_clause_range_check_faile
*** 1150,1161 ****
    (PTR_OR_REF_CHECK (NODE)->base.static_flag)
  
  /* In an INTEGER_CST, REAL_CST, COMPLEX_CST, or VECTOR_CST, this means
!    there was an overflow in folding, and no warning has been issued
!    for this subexpression.  TREE_OVERFLOW implies TREE_CONSTANT_OVERFLOW,
!    but not vice versa.  */
  
  #define TREE_OVERFLOW(NODE) (CST_CHECK (NODE)->base.public_flag)
  
  /* TREE_OVERFLOW can only be true for EXPR of CONSTANT_CLASS_P.  */
  
  #define TREE_OVERFLOW_P(EXPR) \
--- 1142,1154 ----
    (PTR_OR_REF_CHECK (NODE)->base.static_flag)
  
  /* In an INTEGER_CST, REAL_CST, COMPLEX_CST, or VECTOR_CST, this means
!    there was an overflow in folding.  */
  
  #define TREE_OVERFLOW(NODE) (CST_CHECK (NODE)->base.public_flag)
  
+ /* ??? This is an obsolete synonym for TREE_OVERFLOW.  */
+ #define TREE_CONSTANT_OVERFLOW(NODE) TREE_OVERFLOW(NODE)
+ 
  /* TREE_OVERFLOW can only be true for EXPR of CONSTANT_CLASS_P.  */
  
  #define TREE_OVERFLOW_P(EXPR) \

[-- Attachment #3: patchc2.txt --]
[-- Type: text/plain, Size: 46001 bytes --]

Index: builtins.c
===================================================================
*** builtins.c	(revision 120520)
--- builtins.c	(working copy)
***************
*** 1,6 ****
  /* Expand builtin functions.
     Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
!    2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
  
  This file is part of GCC.
  
--- 1,7 ----
  /* Expand builtin functions.
     Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
!    2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
!    Free Software Foundation, Inc.
  
  This file is part of GCC.
  
*************** expand_builtin_pow (tree exp, rtx target
*** 2688,2694 ****
    arg1 = TREE_VALUE (TREE_CHAIN (arglist));
  
    if (TREE_CODE (arg1) != REAL_CST
!       || TREE_CONSTANT_OVERFLOW (arg1))
      return expand_builtin_mathfn_2 (exp, target, subtarget);
  
    /* Handle constant exponents.  */
--- 2689,2695 ----
    arg1 = TREE_VALUE (TREE_CHAIN (arglist));
  
    if (TREE_CODE (arg1) != REAL_CST
!       || TREE_OVERFLOW (arg1))
      return expand_builtin_mathfn_2 (exp, target, subtarget);
  
    /* Handle constant exponents.  */
*************** expand_builtin_powi (tree exp, rtx targe
*** 2821,2827 ****
    /* Handle constant power.  */
  
    if (TREE_CODE (arg1) == INTEGER_CST
!       && ! TREE_CONSTANT_OVERFLOW (arg1))
      {
        HOST_WIDE_INT n = TREE_INT_CST_LOW (arg1);
  
--- 2822,2828 ----
    /* Handle constant power.  */
  
    if (TREE_CODE (arg1) == INTEGER_CST
!       && !TREE_OVERFLOW (arg1))
      {
        HOST_WIDE_INT n = TREE_INT_CST_LOW (arg1);
  
*************** fold_builtin_cabs (tree arglist, tree ty
*** 7013,7020 ****
        && TREE_CODE (arg) == COMPLEX_CST
        && TREE_CODE (TREE_REALPART (arg)) == REAL_CST
        && TREE_CODE (TREE_IMAGPART (arg)) == REAL_CST
!       && ! TREE_CONSTANT_OVERFLOW (TREE_REALPART (arg))
!       && ! TREE_CONSTANT_OVERFLOW (TREE_IMAGPART (arg)))
      {
        REAL_VALUE_TYPE r, i;
  
--- 7014,7021 ----
        && TREE_CODE (arg) == COMPLEX_CST
        && TREE_CODE (TREE_REALPART (arg)) == REAL_CST
        && TREE_CODE (TREE_IMAGPART (arg)) == REAL_CST
!       && !TREE_OVERFLOW (TREE_REALPART (arg))
!       && !TREE_OVERFLOW (TREE_IMAGPART (arg)))
      {
        REAL_VALUE_TYPE r, i;
  
*************** fold_builtin_sqrt (tree arglist, tree ty
*** 7092,7098 ****
  
    /* Optimize sqrt of constant value.  */
    if (TREE_CODE (arg) == REAL_CST
!       && ! TREE_CONSTANT_OVERFLOW (arg))
      {
        REAL_VALUE_TYPE r, x;
  
--- 7093,7099 ----
  
    /* Optimize sqrt of constant value.  */
    if (TREE_CODE (arg) == REAL_CST
!       && !TREE_OVERFLOW (arg))
      {
        REAL_VALUE_TYPE r, x;
  
*************** fold_builtin_trunc (tree fndecl, tree ar
*** 7441,7447 ****
  
    /* Optimize trunc of constant value.  */
    arg = TREE_VALUE (arglist);
!   if (TREE_CODE (arg) == REAL_CST && ! TREE_CONSTANT_OVERFLOW (arg))
      {
        REAL_VALUE_TYPE r, x;
        tree type = TREE_TYPE (TREE_TYPE (fndecl));
--- 7442,7448 ----
  
    /* Optimize trunc of constant value.  */
    arg = TREE_VALUE (arglist);
!   if (TREE_CODE (arg) == REAL_CST && !TREE_OVERFLOW (arg))
      {
        REAL_VALUE_TYPE r, x;
        tree type = TREE_TYPE (TREE_TYPE (fndecl));
*************** fold_builtin_floor (tree fndecl, tree ar
*** 7467,7473 ****
  
    /* Optimize floor of constant value.  */
    arg = TREE_VALUE (arglist);
!   if (TREE_CODE (arg) == REAL_CST && ! TREE_CONSTANT_OVERFLOW (arg))
      {
        REAL_VALUE_TYPE x;
  
--- 7468,7474 ----
  
    /* Optimize floor of constant value.  */
    arg = TREE_VALUE (arglist);
!   if (TREE_CODE (arg) == REAL_CST && !TREE_OVERFLOW (arg))
      {
        REAL_VALUE_TYPE x;
  
*************** fold_builtin_ceil (tree fndecl, tree arg
*** 7506,7512 ****
  
    /* Optimize ceil of constant value.  */
    arg = TREE_VALUE (arglist);
!   if (TREE_CODE (arg) == REAL_CST && ! TREE_CONSTANT_OVERFLOW (arg))
      {
        REAL_VALUE_TYPE x;
  
--- 7507,7513 ----
  
    /* Optimize ceil of constant value.  */
    arg = TREE_VALUE (arglist);
!   if (TREE_CODE (arg) == REAL_CST && !TREE_OVERFLOW (arg))
      {
        REAL_VALUE_TYPE x;
  
*************** fold_builtin_round (tree fndecl, tree ar
*** 7537,7543 ****
  
    /* Optimize round of constant value.  */
    arg = TREE_VALUE (arglist);
!   if (TREE_CODE (arg) == REAL_CST && ! TREE_CONSTANT_OVERFLOW (arg))
      {
        REAL_VALUE_TYPE x;
  
--- 7538,7544 ----
  
    /* Optimize round of constant value.  */
    arg = TREE_VALUE (arglist);
!   if (TREE_CODE (arg) == REAL_CST && !TREE_OVERFLOW (arg))
      {
        REAL_VALUE_TYPE x;
  
*************** fold_builtin_int_roundingfn (tree fndecl
*** 7569,7575 ****
  
    /* Optimize lround of constant value.  */
    arg = TREE_VALUE (arglist);
!   if (TREE_CODE (arg) == REAL_CST && ! TREE_CONSTANT_OVERFLOW (arg))
      {
        const REAL_VALUE_TYPE x = TREE_REAL_CST (arg);
  
--- 7570,7576 ----
  
    /* Optimize lround of constant value.  */
    arg = TREE_VALUE (arglist);
!   if (TREE_CODE (arg) == REAL_CST && !TREE_OVERFLOW (arg))
      {
        const REAL_VALUE_TYPE x = TREE_REAL_CST (arg);
  
*************** fold_builtin_bitop (tree fndecl, tree ar
*** 7637,7643 ****
  
    /* Optimize for constant argument.  */
    arg = TREE_VALUE (arglist);
!   if (TREE_CODE (arg) == INTEGER_CST && ! TREE_CONSTANT_OVERFLOW (arg))
      {
        HOST_WIDE_INT hi, width, result;
        unsigned HOST_WIDE_INT lo;
--- 7638,7644 ----
  
    /* Optimize for constant argument.  */
    arg = TREE_VALUE (arglist);
!   if (TREE_CODE (arg) == INTEGER_CST && !TREE_OVERFLOW (arg))
      {
        HOST_WIDE_INT hi, width, result;
        unsigned HOST_WIDE_INT lo;
*************** fold_builtin_bswap (tree fndecl, tree ar
*** 7729,7735 ****
  
    /* Optimize constant value.  */
    arg = TREE_VALUE (arglist);
!   if (TREE_CODE (arg) == INTEGER_CST && ! TREE_CONSTANT_OVERFLOW (arg))
      {
        HOST_WIDE_INT hi, width, r_hi = 0;
        unsigned HOST_WIDE_INT lo, r_lo = 0;
--- 7730,7736 ----
  
    /* Optimize constant value.  */
    arg = TREE_VALUE (arglist);
!   if (TREE_CODE (arg) == INTEGER_CST && !TREE_OVERFLOW (arg))
      {
        HOST_WIDE_INT hi, width, r_hi = 0;
        unsigned HOST_WIDE_INT lo, r_lo = 0;
*************** real_dconstp (tree expr, const REAL_VALU
*** 7786,7792 ****
    STRIP_NOPS (expr);
  
    return ((TREE_CODE (expr) == REAL_CST
! 	   && ! TREE_CONSTANT_OVERFLOW (expr)
  	   && REAL_VALUES_EQUAL (TREE_REAL_CST (expr), *value))
  	  || (TREE_CODE (expr) == COMPLEX_CST
  	      && real_dconstp (TREE_REALPART (expr), value)
--- 7787,7793 ----
    STRIP_NOPS (expr);
  
    return ((TREE_CODE (expr) == REAL_CST
! 	   && !TREE_OVERFLOW (expr)
  	   && REAL_VALUES_EQUAL (TREE_REAL_CST (expr), *value))
  	  || (TREE_CODE (expr) == COMPLEX_CST
  	      && real_dconstp (TREE_REALPART (expr), value)
*************** fold_builtin_pow (tree fndecl, tree argl
*** 7968,7974 ****
      return omit_one_operand (type, build_real (type, dconst1), arg1);
  
    if (TREE_CODE (arg1) == REAL_CST
!       && ! TREE_CONSTANT_OVERFLOW (arg1))
      {
        REAL_VALUE_TYPE cint;
        REAL_VALUE_TYPE c;
--- 7969,7975 ----
      return omit_one_operand (type, build_real (type, dconst1), arg1);
  
    if (TREE_CODE (arg1) == REAL_CST
!       && !TREE_OVERFLOW (arg1))
      {
        REAL_VALUE_TYPE cint;
        REAL_VALUE_TYPE c;
*************** fold_builtin_pow (tree fndecl, tree argl
*** 8027,8033 ****
  	{
  	  /* Attempt to evaluate pow at compile-time.  */
  	  if (TREE_CODE (arg0) == REAL_CST
! 	      && ! TREE_CONSTANT_OVERFLOW (arg0))
  	    {
  	      REAL_VALUE_TYPE x;
  	      bool inexact;
--- 8028,8034 ----
  	{
  	  /* Attempt to evaluate pow at compile-time.  */
  	  if (TREE_CODE (arg0) == REAL_CST
! 	      && !TREE_OVERFLOW (arg0))
  	    {
  	      REAL_VALUE_TYPE x;
  	      bool inexact;
*************** fold_builtin_powi (tree fndecl ATTRIBUTE
*** 8131,8137 ****
  
        /* Evaluate powi at compile-time.  */
        if (TREE_CODE (arg0) == REAL_CST
! 	  && ! TREE_CONSTANT_OVERFLOW (arg0))
  	{
  	  REAL_VALUE_TYPE x;
  	  x = TREE_REAL_CST (arg0);
--- 8132,8138 ----
  
        /* Evaluate powi at compile-time.  */
        if (TREE_CODE (arg0) == REAL_CST
! 	  && !TREE_OVERFLOW (arg0))
  	{
  	  REAL_VALUE_TYPE x;
  	  x = TREE_REAL_CST (arg0);
*************** fold_builtin_signbit (tree fndecl, tree 
*** 8819,8825 ****
  
    /* If ARG is a compile-time constant, determine the result.  */
    if (TREE_CODE (arg) == REAL_CST
!       && !TREE_CONSTANT_OVERFLOW (arg))
      {
        REAL_VALUE_TYPE c;
  
--- 8820,8826 ----
  
    /* If ARG is a compile-time constant, determine the result.  */
    if (TREE_CODE (arg) == REAL_CST
!       && !TREE_OVERFLOW (arg))
      {
        REAL_VALUE_TYPE c;
  
*************** fold_builtin_copysign (tree fndecl, tree
*** 8861,8868 ****
    /* If ARG1 and ARG2 are compile-time constants, determine the result.  */
    if (TREE_CODE (arg1) == REAL_CST
        && TREE_CODE (arg2) == REAL_CST
!       && !TREE_CONSTANT_OVERFLOW (arg1)
!       && !TREE_CONSTANT_OVERFLOW (arg2))
      {
        REAL_VALUE_TYPE c1, c2;
  
--- 8862,8869 ----
    /* If ARG1 and ARG2 are compile-time constants, determine the result.  */
    if (TREE_CODE (arg1) == REAL_CST
        && TREE_CODE (arg2) == REAL_CST
!       && !TREE_OVERFLOW (arg1)
!       && !TREE_OVERFLOW (arg2))
      {
        REAL_VALUE_TYPE c1, c2;
  
*************** fold_builtin_object_size (tree arglist)
*** 10832,10838 ****
    if (ret)
      {
        ret = force_fit_type (ret, -1, false, false);
!       if (TREE_CONSTANT_OVERFLOW (ret))
  	ret = 0;
      }
  
--- 10833,10839 ----
    if (ret)
      {
        ret = force_fit_type (ret, -1, false, false);
!       if (TREE_OVERFLOW (ret))
  	ret = 0;
      }
  
*************** do_mpfr_arg1 (tree arg, tree type, int (
*** 11740,11746 ****
    /* To proceed, MPFR must exactly represent the target floating point
       format, which only happens when the target base equals two.  */
    if (REAL_MODE_FORMAT (TYPE_MODE (type))->b == 2
!       && TREE_CODE (arg) == REAL_CST && ! TREE_CONSTANT_OVERFLOW (arg))
      {
        const REAL_VALUE_TYPE *const ra = &TREE_REAL_CST (arg);
  
--- 11741,11747 ----
    /* To proceed, MPFR must exactly represent the target floating point
       format, which only happens when the target base equals two.  */
    if (REAL_MODE_FORMAT (TYPE_MODE (type))->b == 2
!       && TREE_CODE (arg) == REAL_CST && !TREE_OVERFLOW (arg))
      {
        const REAL_VALUE_TYPE *const ra = &TREE_REAL_CST (arg);
  
*************** do_mpfr_arg2 (tree arg1, tree arg2, tree
*** 11782,11789 ****
    /* To proceed, MPFR must exactly represent the target floating point
       format, which only happens when the target base equals two.  */
    if (REAL_MODE_FORMAT (TYPE_MODE (type))->b == 2
!       && TREE_CODE (arg1) == REAL_CST && ! TREE_CONSTANT_OVERFLOW (arg1)
!       && TREE_CODE (arg2) == REAL_CST && ! TREE_CONSTANT_OVERFLOW (arg2))
      {
        const REAL_VALUE_TYPE *const ra1 = &TREE_REAL_CST (arg1);
        const REAL_VALUE_TYPE *const ra2 = &TREE_REAL_CST (arg2);
--- 11783,11790 ----
    /* To proceed, MPFR must exactly represent the target floating point
       format, which only happens when the target base equals two.  */
    if (REAL_MODE_FORMAT (TYPE_MODE (type))->b == 2
!       && TREE_CODE (arg1) == REAL_CST && !TREE_OVERFLOW (arg1)
!       && TREE_CODE (arg2) == REAL_CST && !TREE_OVERFLOW (arg2))
      {
        const REAL_VALUE_TYPE *const ra1 = &TREE_REAL_CST (arg1);
        const REAL_VALUE_TYPE *const ra2 = &TREE_REAL_CST (arg2);
*************** do_mpfr_arg3 (tree arg1, tree arg2, tree
*** 11827,11835 ****
    /* To proceed, MPFR must exactly represent the target floating point
       format, which only happens when the target base equals two.  */
    if (REAL_MODE_FORMAT (TYPE_MODE (type))->b == 2
!       && TREE_CODE (arg1) == REAL_CST && ! TREE_CONSTANT_OVERFLOW (arg1)
!       && TREE_CODE (arg2) == REAL_CST && ! TREE_CONSTANT_OVERFLOW (arg2)
!       && TREE_CODE (arg3) == REAL_CST && ! TREE_CONSTANT_OVERFLOW (arg3))
      {
        const REAL_VALUE_TYPE *const ra1 = &TREE_REAL_CST (arg1);
        const REAL_VALUE_TYPE *const ra2 = &TREE_REAL_CST (arg2);
--- 11828,11836 ----
    /* To proceed, MPFR must exactly represent the target floating point
       format, which only happens when the target base equals two.  */
    if (REAL_MODE_FORMAT (TYPE_MODE (type))->b == 2
!       && TREE_CODE (arg1) == REAL_CST && !TREE_OVERFLOW (arg1)
!       && TREE_CODE (arg2) == REAL_CST && !TREE_OVERFLOW (arg2)
!       && TREE_CODE (arg3) == REAL_CST && !TREE_OVERFLOW (arg3))
      {
        const REAL_VALUE_TYPE *const ra1 = &TREE_REAL_CST (arg1);
        const REAL_VALUE_TYPE *const ra2 = &TREE_REAL_CST (arg2);
*************** do_mpfr_sincos (tree arg, tree arg_sinp,
*** 11875,11881 ****
    /* To proceed, MPFR must exactly represent the target floating point
       format, which only happens when the target base equals two.  */
    if (REAL_MODE_FORMAT (TYPE_MODE (type))->b == 2
!       && TREE_CODE (arg) == REAL_CST && ! TREE_CONSTANT_OVERFLOW (arg))
      {
        const REAL_VALUE_TYPE *const ra = &TREE_REAL_CST (arg);
  
--- 11876,11883 ----
    /* To proceed, MPFR must exactly represent the target floating point
       format, which only happens when the target base equals two.  */
    if (REAL_MODE_FORMAT (TYPE_MODE (type))->b == 2
!       && TREE_CODE (arg) == REAL_CST
!       && !TREE_OVERFLOW (arg))
      {
        const REAL_VALUE_TYPE *const ra = &TREE_REAL_CST (arg);
  
Index: convert.c
===================================================================
*** convert.c	(revision 120520)
--- convert.c	(working copy)
***************
*** 1,6 ****
  /* Utility routines for data type conversion for GCC.
     Copyright (C) 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1997, 1998,
!    2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
  
  This file is part of GCC.
  
--- 1,7 ----
  /* Utility routines for data type conversion for GCC.
     Copyright (C) 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1997, 1998,
!    2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
!    Free Software Foundation, Inc.
  
  This file is part of GCC.
  
*************** convert_to_pointer (tree type, tree expr
*** 47,55 ****
    if (integer_zerop (expr))
      {
        tree t = build_int_cst (type, 0);
!       if (TREE_OVERFLOW (expr) || TREE_CONSTANT_OVERFLOW (expr))
! 	t = force_fit_type (t, 0, TREE_OVERFLOW (expr),
! 			    TREE_CONSTANT_OVERFLOW (expr));
        return t;
      }
  
--- 48,55 ----
    if (integer_zerop (expr))
      {
        tree t = build_int_cst (type, 0);
!       if (TREE_OVERFLOW (expr))
! 	t = force_fit_type (t, 0, TREE_OVERFLOW (expr), false);
        return t;
      }
  
Index: expr.c
===================================================================
*** expr.c	(revision 120520)
--- expr.c	(working copy)
***************
*** 1,7 ****
  /* Convert tree expression to rtl instructions, for GNU compiler.
     Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
!    2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
!    Inc.
  
  This file is part of GCC.
  
--- 1,7 ----
  /* Convert tree expression to rtl instructions, for GNU compiler.
     Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
!    2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
!    Free Software Foundation, Inc.
  
  This file is part of GCC.
  
*************** highest_pow2_factor (tree exp)
*** 6301,6307 ****
  	 a MIN_EXPR, or a MAX_EXPR.  If the constant overflows, we have an
  	 erroneous program, so return BIGGEST_ALIGNMENT to avoid any
  	 later ICE.  */
!       if (TREE_CONSTANT_OVERFLOW (exp))
  	return BIGGEST_ALIGNMENT;
        else
  	{
--- 6301,6307 ----
  	 a MIN_EXPR, or a MAX_EXPR.  If the constant overflows, we have an
  	 erroneous program, so return BIGGEST_ALIGNMENT to avoid any
  	 later ICE.  */
!       if (TREE_OVERFLOW (exp))
  	return BIGGEST_ALIGNMENT;
        else
  	{
*************** expand_expr_real_1 (tree exp, rtx target
*** 6969,6975 ****
  	 simplified by validate_replace_rtx during virtual register
  	 instantiation, which can result in unrecognizable insns.
  	 Avoid this by forcing all overflows into registers.  */
!       if (TREE_CONSTANT_OVERFLOW (exp)
  	  && modifier != EXPAND_INITIALIZER)
  	temp = force_reg (mode, temp);
  
--- 6969,6975 ----
  	 simplified by validate_replace_rtx during virtual register
  	 instantiation, which can result in unrecognizable insns.
  	 Avoid this by forcing all overflows into registers.  */
!       if (TREE_OVERFLOW (exp)
  	  && modifier != EXPAND_INITIALIZER)
  	temp = force_reg (mode, temp);
  
Index: fold-const.c
===================================================================
*** fold-const.c	(revision 120520)
--- fold-const.c	(working copy)
***************
*** 1,6 ****
  /* Fold a constant sub-tree into a single node for C-compiler
     Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
!    2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
  
  This file is part of GCC.
  
--- 1,7 ----
  /* Fold a constant sub-tree into a single node for C-compiler
     Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
!    2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
!    Free Software Foundation, Inc.
  
  This file is part of GCC.
  
*************** Software Foundation, 51 Franklin Street,
*** 41,47 ****
  
     force_fit_type takes a constant, an overflowable flag and prior
     overflow indicators.  It forces the value to fit the type and sets
!    TREE_OVERFLOW and TREE_CONSTANT_OVERFLOW as appropriate.
     
     Note: Since the folders get called on non-gimple code as well as
     gimple code, we need to handle GIMPLE tuples as well as their
--- 42,48 ----
  
     force_fit_type takes a constant, an overflowable flag and prior
     overflow indicators.  It forces the value to fit the type and sets
!    TREE_OVERFLOW as appropriate.
     
     Note: Since the folders get called on non-gimple code as well as
     gimple code, we need to handle GIMPLE tuples as well as their
*************** decode (HOST_WIDE_INT *words, unsigned H
*** 202,210 ****
    	OVERFLOWED is nonzero,
  	or OVERFLOWABLE is >0 and signed overflow occurs
  	or OVERFLOWABLE is <0 and any overflow occurs
-    We set TREE_CONSTANT_OVERFLOWED if,
-         CONST_OVERFLOWED is nonzero
- 	or we set TREE_OVERFLOWED.
    We return either the original T, or a copy.  */
  
  tree
--- 203,208 ----
*************** force_fit_type (tree t, int overflowable
*** 282,293 ****
  	{
  	  t = copy_node (t);
  	  TREE_OVERFLOW (t) = 1;
- 	  TREE_CONSTANT_OVERFLOW (t) = 1;
- 	}
-       else if (overflowed_const)
- 	{
- 	  t = copy_node (t);
- 	  TREE_CONSTANT_OVERFLOW (t) = 1;
  	}
      }
  
--- 280,285 ----
*************** fold_negate_expr (tree t)
*** 1081,1096 ****
        
      case INTEGER_CST:
        tem = fold_negate_const (t, type);
!       if (! TREE_OVERFLOW (tem)
  	  || TYPE_UNSIGNED (type)
! 	  || ! flag_trapv)
  	return tem;
        break;
  
      case REAL_CST:
        tem = fold_negate_const (t, type);
        /* Two's complement FP formats, such as c4x, may overflow.  */
!       if (! TREE_OVERFLOW (tem) || ! flag_trapping_math)
  	return tem;
        break;
  
--- 1073,1088 ----
        
      case INTEGER_CST:
        tem = fold_negate_const (t, type);
!       if (!TREE_OVERFLOW (tem)
  	  || TYPE_UNSIGNED (type)
! 	  || !flag_trapv)
  	return tem;
        break;
  
      case REAL_CST:
        tem = fold_negate_const (t, type);
        /* Two's complement FP formats, such as c4x, may overflow.  */
!       if (!TREE_OVERFLOW (tem) || !flag_trapping_math)
  	return tem;
        break;
  
*************** int_const_binop (enum tree_code code, tr
*** 1496,1503 ****
      case EXACT_DIV_EXPR:
        /* This is a shortcut for a common special case.  */
        if (int2h == 0 && (HOST_WIDE_INT) int2l > 0
! 	  && ! TREE_CONSTANT_OVERFLOW (arg1)
! 	  && ! TREE_CONSTANT_OVERFLOW (arg2)
  	  && int1h == 0 && (HOST_WIDE_INT) int1l >= 0)
  	{
  	  if (code == CEIL_DIV_EXPR)
--- 1488,1495 ----
      case EXACT_DIV_EXPR:
        /* This is a shortcut for a common special case.  */
        if (int2h == 0 && (HOST_WIDE_INT) int2l > 0
! 	  && !TREE_OVERFLOW (arg1)
! 	  && !TREE_OVERFLOW (arg2)
  	  && int1h == 0 && (HOST_WIDE_INT) int1l >= 0)
  	{
  	  if (code == CEIL_DIV_EXPR)
*************** int_const_binop (enum tree_code code, tr
*** 1531,1538 ****
      case FLOOR_MOD_EXPR: case CEIL_MOD_EXPR:
        /* This is a shortcut for a common special case.  */
        if (int2h == 0 && (HOST_WIDE_INT) int2l > 0
! 	  && ! TREE_CONSTANT_OVERFLOW (arg1)
! 	  && ! TREE_CONSTANT_OVERFLOW (arg2)
  	  && int1h == 0 && (HOST_WIDE_INT) int1l >= 0)
  	{
  	  if (code == CEIL_MOD_EXPR)
--- 1523,1530 ----
      case FLOOR_MOD_EXPR: case CEIL_MOD_EXPR:
        /* This is a shortcut for a common special case.  */
        if (int2h == 0 && (HOST_WIDE_INT) int2l > 0
! 	  && !TREE_OVERFLOW (arg1)
! 	  && !TREE_OVERFLOW (arg2)
  	  && int1h == 0 && (HOST_WIDE_INT) int1l >= 0)
  	{
  	  if (code == CEIL_MOD_EXPR)
*************** int_const_binop (enum tree_code code, tr
*** 1583,1602 ****
  	{
  	  t = copy_node (t);
  	  TREE_OVERFLOW (t) = 1;
- 	  TREE_CONSTANT_OVERFLOW (t) = 1;
- 	}
-       else if (TREE_CONSTANT_OVERFLOW (arg1) | TREE_CONSTANT_OVERFLOW (arg2))
- 	{
- 	  t = copy_node (t);
- 	  TREE_CONSTANT_OVERFLOW (t) = 1;
  	}
      }
    else
      t = force_fit_type (t, 1,
  			((!uns || is_sizetype) && overflow)
  			| TREE_OVERFLOW (arg1) | TREE_OVERFLOW (arg2),
! 			TREE_CONSTANT_OVERFLOW (arg1)
! 			| TREE_CONSTANT_OVERFLOW (arg2));
  
    return t;
  }
--- 1575,1587 ----
  	{
  	  t = copy_node (t);
  	  TREE_OVERFLOW (t) = 1;
  	}
      }
    else
      t = force_fit_type (t, 1,
  			((!uns || is_sizetype) && overflow)
  			| TREE_OVERFLOW (arg1) | TREE_OVERFLOW (arg2),
! 			false);
  
    return t;
  }
*************** const_binop (enum tree_code code, tree a
*** 1697,1706 ****
        t = build_real (type, result);
  
        TREE_OVERFLOW (t) = TREE_OVERFLOW (arg1) | TREE_OVERFLOW (arg2);
-       TREE_CONSTANT_OVERFLOW (t)
- 	= TREE_OVERFLOW (t)
- 	  | TREE_CONSTANT_OVERFLOW (arg1)
- 	  | TREE_CONSTANT_OVERFLOW (arg2);
        return t;
      }
  
--- 1682,1687 ----
*************** fold_convert_const_int_from_int (tree ty
*** 1879,1885 ****
  		       && (TYPE_UNSIGNED (type)
  			   < TYPE_UNSIGNED (TREE_TYPE (arg1))))
  		      | TREE_OVERFLOW (arg1),
! 		      TREE_CONSTANT_OVERFLOW (arg1));
  
    return t;
  }
--- 1860,1866 ----
  		       && (TYPE_UNSIGNED (type)
  			   < TYPE_UNSIGNED (TREE_TYPE (arg1))))
  		      | TREE_OVERFLOW (arg1),
! 		      false);
  
    return t;
  }
*************** fold_convert_const_int_from_real (enum t
*** 1959,1966 ****
  
    t = build_int_cst_wide (type, low, high);
  
!   t = force_fit_type (t, -1, overflow | TREE_OVERFLOW (arg1),
! 		      TREE_CONSTANT_OVERFLOW (arg1));
    return t;
  }
  
--- 1940,1946 ----
  
    t = build_int_cst_wide (type, low, high);
  
!   t = force_fit_type (t, -1, overflow | TREE_OVERFLOW (arg1), false);
    return t;
  }
  
*************** fold_convert_const_real_from_real (tree 
*** 1977,1984 ****
    t = build_real (type, value);
  
    TREE_OVERFLOW (t) = TREE_OVERFLOW (arg1);
-   TREE_CONSTANT_OVERFLOW (t)
-     = TREE_OVERFLOW (t) | TREE_CONSTANT_OVERFLOW (arg1);
    return t;
  }
  
--- 1957,1962 ----
*************** sign_bit_p (tree exp, tree val)
*** 3669,3675 ****
  
    /* Tree VAL must be an integer constant.  */
    if (TREE_CODE (val) != INTEGER_CST
!       || TREE_CONSTANT_OVERFLOW (val))
      return NULL_TREE;
  
    width = TYPE_PRECISION (t);
--- 3647,3653 ----
  
    /* Tree VAL must be an integer constant.  */
    if (TREE_CODE (val) != INTEGER_CST
!       || TREE_OVERFLOW (val))
      return NULL_TREE;
  
    width = TYPE_PRECISION (t);
*************** optimize_minmax_comparison (enum tree_co
*** 5325,5333 ****
    /* If something does not permit us to optimize, return the original tree.  */
    if ((op_code != MIN_EXPR && op_code != MAX_EXPR)
        || TREE_CODE (comp_const) != INTEGER_CST
!       || TREE_CONSTANT_OVERFLOW (comp_const)
        || TREE_CODE (minmax_const) != INTEGER_CST
!       || TREE_CONSTANT_OVERFLOW (minmax_const))
      return NULL_TREE;
  
    /* Now handle all the various comparison codes.  We only handle EQ_EXPR
--- 5303,5311 ----
    /* If something does not permit us to optimize, return the original tree.  */
    if ((op_code != MIN_EXPR && op_code != MAX_EXPR)
        || TREE_CODE (comp_const) != INTEGER_CST
!       || TREE_OVERFLOW (comp_const)
        || TREE_CODE (minmax_const) != INTEGER_CST
!       || TREE_OVERFLOW (minmax_const))
      return NULL_TREE;
  
    /* Now handle all the various comparison codes.  We only handle EQ_EXPR
*************** extract_muldiv_1 (tree t, tree c, enum t
*** 5504,5510 ****
  	 possible later conversion to our or some other type.  */
        if ((t2 = fold_convert (TREE_TYPE (op0), c)) != 0
  	  && TREE_CODE (t2) == INTEGER_CST
! 	  && ! TREE_CONSTANT_OVERFLOW (t2)
  	  && (0 != (t1 = extract_muldiv (op0, t2, code,
  					 code == MULT_EXPR
  					 ? ctype : NULL_TREE))))
--- 5482,5488 ----
  	 possible later conversion to our or some other type.  */
        if ((t2 = fold_convert (TREE_TYPE (op0), c)) != 0
  	  && TREE_CODE (t2) == INTEGER_CST
! 	  && !TREE_OVERFLOW (t2)
  	  && (0 != (t1 = extract_muldiv (op0, t2, code,
  					 code == MULT_EXPR
  					 ? ctype : NULL_TREE))))
*************** extract_muldiv_1 (tree t, tree c, enum t
*** 5565,5571 ****
  				      const_binop (LSHIFT_EXPR,
  						   size_one_node,
  						   op1, 0)))
! 	  && ! TREE_OVERFLOW (t1))
  	return extract_muldiv (build2 (tcode == LSHIFT_EXPR
  				       ? MULT_EXPR : FLOOR_DIV_EXPR,
  				       ctype, fold_convert (ctype, op0), t1),
--- 5543,5549 ----
  				      const_binop (LSHIFT_EXPR,
  						   size_one_node,
  						   op1, 0)))
! 	  && !TREE_OVERFLOW (t1))
  	return extract_muldiv (build2 (tcode == LSHIFT_EXPR
  				       ? MULT_EXPR : FLOOR_DIV_EXPR,
  				       ctype, fold_convert (ctype, op0), t1),
*************** extract_muldiv_1 (tree t, tree c, enum t
*** 5682,5688 ****
        if (tcode == code
  	  && 0 != (t1 = const_binop (MULT_EXPR, fold_convert (ctype, op1),
  				     fold_convert (ctype, c), 0))
! 	  && ! TREE_OVERFLOW (t1))
  	return fold_build2 (tcode, ctype, fold_convert (ctype, op0), t1);
  
        /* If these operations "cancel" each other, we have the main
--- 5660,5666 ----
        if (tcode == code
  	  && 0 != (t1 = const_binop (MULT_EXPR, fold_convert (ctype, op1),
  				     fold_convert (ctype, c), 0))
! 	  && !TREE_OVERFLOW (t1))
  	return fold_build2 (tcode, ctype, fold_convert (ctype, op0), t1);
  
        /* If these operations "cancel" each other, we have the main
*************** fold_div_compare (enum tree_code code, t
*** 6165,6172 ****
  				       TREE_INT_CST_HIGH (tmp),
  				       &lpart, &hpart, unsigned_p);
        hi = build_int_cst_wide (TREE_TYPE (arg00), lpart, hpart);
!       hi = force_fit_type (hi, -1, overflow | TREE_OVERFLOW (prod),
! 			   TREE_CONSTANT_OVERFLOW (prod));
      }
    else if (tree_int_cst_sgn (arg01) >= 0)
      {
--- 6143,6149 ----
  				       TREE_INT_CST_HIGH (tmp),
  				       &lpart, &hpart, unsigned_p);
        hi = build_int_cst_wide (TREE_TYPE (arg00), lpart, hpart);
!       hi = force_fit_type (hi, -1, overflow | TREE_OVERFLOW (prod), false);
      }
    else if (tree_int_cst_sgn (arg01) >= 0)
      {
*************** fold_sign_changed_comparison (enum tree_
*** 6604,6612 ****
        tmp = build_int_cst_wide (inner_type,
  				TREE_INT_CST_LOW (arg1),
  				TREE_INT_CST_HIGH (arg1));
!       arg1 = force_fit_type (tmp, 0,
! 			     TREE_OVERFLOW (arg1),
! 			     TREE_CONSTANT_OVERFLOW (arg1));
      }
    else
      arg1 = fold_convert (inner_type, arg1);
--- 6581,6587 ----
        tmp = build_int_cst_wide (inner_type,
  				TREE_INT_CST_LOW (arg1),
  				TREE_INT_CST_HIGH (arg1));
!       arg1 = force_fit_type (tmp, 0, TREE_OVERFLOW (arg1), false);
      }
    else
      arg1 = fold_convert (inner_type, arg1);
*************** fold_unary (enum tree_code code, tree ty
*** 7542,7549 ****
  	    {
  	      tem = build_int_cst_wide (type, TREE_INT_CST_LOW (and1),
  					TREE_INT_CST_HIGH (and1));
! 	      tem = force_fit_type (tem, 0, TREE_OVERFLOW (and1),
! 				    TREE_CONSTANT_OVERFLOW (and1));
  	      return fold_build2 (BIT_AND_EXPR, type,
  				  fold_convert (type, and0), tem);
  	    }
--- 7517,7523 ----
  	    {
  	      tem = build_int_cst_wide (type, TREE_INT_CST_LOW (and1),
  					TREE_INT_CST_HIGH (and1));
! 	      tem = force_fit_type (tem, 0, TREE_OVERFLOW (and1), false);
  	      return fold_build2 (BIT_AND_EXPR, type,
  				  fold_convert (type, and0), tem);
  	    }
*************** fold_comparison (enum tree_code code, tr
*** 8243,8249 ****
  	  && 0 != (tem = const_binop (TREE_CODE (arg0) == PLUS_EXPR
  				      ? MINUS_EXPR : PLUS_EXPR,
  				      arg1, TREE_OPERAND (arg0, 1), 0))
! 	  && ! TREE_CONSTANT_OVERFLOW (tem))
  	return fold_build2 (code, type, TREE_OPERAND (arg0, 0), tem);
  
        /* Likewise, we can simplify a comparison of a real constant with
--- 8217,8223 ----
  	  && 0 != (tem = const_binop (TREE_CODE (arg0) == PLUS_EXPR
  				      ? MINUS_EXPR : PLUS_EXPR,
  				      arg1, TREE_OPERAND (arg0, 1), 0))
! 	  && !TREE_OVERFLOW (tem))
  	return fold_build2 (code, type, TREE_OPERAND (arg0, 0), tem);
  
        /* Likewise, we can simplify a comparison of a real constant with
*************** fold_comparison (enum tree_code code, tr
*** 8255,8261 ****
  	  && TREE_CODE (TREE_OPERAND (arg0, 0)) == REAL_CST
  	  && 0 != (tem = const_binop (MINUS_EXPR, TREE_OPERAND (arg0, 0),
  				      arg1, 0))
! 	  && ! TREE_CONSTANT_OVERFLOW (tem))
  	return fold_build2 (swap_tree_comparison (code), type,
  			    TREE_OPERAND (arg0, 1), tem);
  
--- 8229,8235 ----
  	  && TREE_CODE (TREE_OPERAND (arg0, 0)) == REAL_CST
  	  && 0 != (tem = const_binop (MINUS_EXPR, TREE_OPERAND (arg0, 0),
  				      arg1, 0))
! 	  && !TREE_OVERFLOW (tem))
  	return fold_build2 (swap_tree_comparison (code), type,
  			    TREE_OPERAND (arg0, 1), tem);
  
*************** fold_binary (enum tree_code code, tree t
*** 9501,9507 ****
  		  tree arg11 = TREE_VALUE (TREE_CHAIN (TREE_OPERAND (arg1,
  								     1)));
  		  if (TREE_CODE (arg11) == REAL_CST
! 		      && ! TREE_CONSTANT_OVERFLOW (arg11)
  		      && operand_equal_p (arg0, arg10, 0))
  		    {
  		      tree powfn = TREE_OPERAND (TREE_OPERAND (arg1, 0), 0);
--- 9475,9481 ----
  		  tree arg11 = TREE_VALUE (TREE_CHAIN (TREE_OPERAND (arg1,
  								     1)));
  		  if (TREE_CODE (arg11) == REAL_CST
! 		      && !TREE_OVERFLOW (arg11)
  		      && operand_equal_p (arg0, arg10, 0))
  		    {
  		      tree powfn = TREE_OPERAND (TREE_OPERAND (arg1, 0), 0);
*************** fold_binary (enum tree_code code, tree t
*** 9526,9532 ****
  		  tree arg01 = TREE_VALUE (TREE_CHAIN (TREE_OPERAND (arg0,
  								     1)));
  		  if (TREE_CODE (arg01) == REAL_CST
! 		      && ! TREE_CONSTANT_OVERFLOW (arg01)
  		      && operand_equal_p (arg1, arg00, 0))
  		    {
  		      tree powfn = TREE_OPERAND (TREE_OPERAND (arg0, 0), 0);
--- 9500,9506 ----
  		  tree arg01 = TREE_VALUE (TREE_CHAIN (TREE_OPERAND (arg0,
  								     1)));
  		  if (TREE_CODE (arg01) == REAL_CST
! 		      && !TREE_OVERFLOW (arg01)
  		      && operand_equal_p (arg1, arg00, 0))
  		    {
  		      tree powfn = TREE_OPERAND (TREE_OPERAND (arg0, 0), 0);
*************** fold_binary (enum tree_code code, tree t
*** 10172,10178 ****
  	      tree arg00 = TREE_VALUE (TREE_OPERAND (arg0, 1));
  	      tree arg01 = TREE_VALUE (TREE_CHAIN (TREE_OPERAND (arg0, 1)));
  	      if (TREE_CODE (arg01) == REAL_CST
! 		  && ! TREE_CONSTANT_OVERFLOW (arg01)
  		  && operand_equal_p (arg1, arg00, 0))
  		{
  		  tree powfn = TREE_OPERAND (TREE_OPERAND (arg0, 0), 0);
--- 10146,10152 ----
  	      tree arg00 = TREE_VALUE (TREE_OPERAND (arg0, 1));
  	      tree arg01 = TREE_VALUE (TREE_CHAIN (TREE_OPERAND (arg0, 1)));
  	      if (TREE_CODE (arg01) == REAL_CST
! 		  && !TREE_OVERFLOW (arg01)
  		  && operand_equal_p (arg1, arg00, 0))
  		{
  		  tree powfn = TREE_OPERAND (TREE_OPERAND (arg0, 0), 0);
*************** fold_binary (enum tree_code code, tree t
*** 10331,10337 ****
        if (code == TRUNC_MOD_EXPR
  	  && !TYPE_UNSIGNED (type)
  	  && TREE_CODE (arg1) == INTEGER_CST
! 	  && !TREE_CONSTANT_OVERFLOW (arg1)
  	  && TREE_INT_CST_HIGH (arg1) < 0
  	  && !flag_trapv
  	  /* Avoid this transformation if C is INT_MIN, i.e. C == -C.  */
--- 10305,10311 ----
        if (code == TRUNC_MOD_EXPR
  	  && !TYPE_UNSIGNED (type)
  	  && TREE_CODE (arg1) == INTEGER_CST
! 	  && !TREE_OVERFLOW (arg1)
  	  && TREE_INT_CST_HIGH (arg1) < 0
  	  && !flag_trapv
  	  /* Avoid this transformation if C is INT_MIN, i.e. C == -C.  */
*************** fold_binary (enum tree_code code, tree t
*** 10745,10751 ****
  				      ? MINUS_EXPR : PLUS_EXPR,
  				      fold_convert (TREE_TYPE (arg0), arg1),
  				      TREE_OPERAND (arg0, 1), 0))
! 	  && ! TREE_CONSTANT_OVERFLOW (tem))
  	return fold_build2 (code, type, TREE_OPERAND (arg0, 0), tem);
  
        /* Similarly for a NEGATE_EXPR.  */
--- 10719,10725 ----
  				      ? MINUS_EXPR : PLUS_EXPR,
  				      fold_convert (TREE_TYPE (arg0), arg1),
  				      TREE_OPERAND (arg0, 1), 0))
! 	  && !TREE_OVERFLOW (tem))
  	return fold_build2 (code, type, TREE_OPERAND (arg0, 0), tem);
  
        /* Similarly for a NEGATE_EXPR.  */
*************** fold_binary (enum tree_code code, tree t
*** 10753,10759 ****
  	  && TREE_CODE (arg1) == INTEGER_CST
  	  && 0 != (tem = negate_expr (arg1))
  	  && TREE_CODE (tem) == INTEGER_CST
! 	  && ! TREE_CONSTANT_OVERFLOW (tem))
  	return fold_build2 (code, type, TREE_OPERAND (arg0, 0), tem);
  
        /* Similarly for a BIT_XOR_EXPR;  X ^ C1 == C2 is X == (C1 ^ C2).  */
--- 10727,10733 ----
  	  && TREE_CODE (arg1) == INTEGER_CST
  	  && 0 != (tem = negate_expr (arg1))
  	  && TREE_CODE (tem) == INTEGER_CST
! 	  && !TREE_OVERFLOW (tem))
  	return fold_build2 (code, type, TREE_OPERAND (arg0, 0), tem);
  
        /* Similarly for a BIT_XOR_EXPR;  X ^ C1 == C2 is X == (C1 ^ C2).  */
*************** fold_binary (enum tree_code code, tree t
*** 11258,11264 ****
  	unsigned int width = TYPE_PRECISION (arg1_type);
  
  	if (TREE_CODE (arg1) == INTEGER_CST
! 	    && ! TREE_CONSTANT_OVERFLOW (arg1)
  	    && width <= 2 * HOST_BITS_PER_WIDE_INT
  	    && (INTEGRAL_TYPE_P (arg1_type) || POINTER_TYPE_P (arg1_type)))
  	  {
--- 11232,11238 ----
  	unsigned int width = TYPE_PRECISION (arg1_type);
  
  	if (TREE_CODE (arg1) == INTEGER_CST
! 	    && !TREE_OVERFLOW (arg1)
  	    && width <= 2 * HOST_BITS_PER_WIDE_INT
  	    && (INTEGRAL_TYPE_P (arg1_type) || POINTER_TYPE_P (arg1_type)))
  	  {
*************** fold_binary (enum tree_code code, tree t
*** 11417,11423 ****
  	  && ! TREE_SIDE_EFFECTS (arg0)
  	  && (0 != (tem = negate_expr (arg1)))
  	  && TREE_CODE (tem) == INTEGER_CST
! 	  && ! TREE_CONSTANT_OVERFLOW (tem))
  	return fold_build2 (TRUTH_ANDIF_EXPR, type,
  			    build2 (GE_EXPR, type,
  				    TREE_OPERAND (arg0, 0), tem),
--- 11391,11397 ----
  	  && ! TREE_SIDE_EFFECTS (arg0)
  	  && (0 != (tem = negate_expr (arg1)))
  	  && TREE_CODE (tem) == INTEGER_CST
! 	  && !TREE_OVERFLOW (tem))
  	return fold_build2 (TRUTH_ANDIF_EXPR, type,
  			    build2 (GE_EXPR, type,
  				    TREE_OPERAND (arg0, 0), tem),
*************** multiple_of_p (tree type, tree top, tree
*** 12481,12487 ****
  					  const_binop (LSHIFT_EXPR,
  						       size_one_node,
  						       op1, 0)))
! 	      && ! TREE_OVERFLOW (t1))
  	    return multiple_of_p (type, t1, bottom);
  	}
        return 0;
--- 12455,12461 ----
  					  const_binop (LSHIFT_EXPR,
  						       size_one_node,
  						       op1, 0)))
! 	      && !TREE_OVERFLOW (t1))
  	    return multiple_of_p (type, t1, bottom);
  	}
        return 0;
*************** tree_expr_nonzero_p (tree t)
*** 12837,12846 ****
        return tree_expr_nonzero_p (TREE_OPERAND (t, 0));
  
      case INTEGER_CST:
!       /* We used to test for !integer_zerop here.  This does not work correctly
! 	 if TREE_CONSTANT_OVERFLOW (t).  */
!       return (TREE_INT_CST_LOW (t) != 0
! 	      || TREE_INT_CST_HIGH (t) != 0);
  
      case PLUS_EXPR:
        if (!TYPE_UNSIGNED (type) && !flag_wrapv)
--- 12811,12817 ----
        return tree_expr_nonzero_p (TREE_OPERAND (t, 0));
  
      case INTEGER_CST:
!       return !integer_zerop (t);
  
      case PLUS_EXPR:
        if (!TYPE_UNSIGNED (type) && !flag_wrapv)
*************** fold_negate_const (tree arg0, tree type)
*** 13043,13049 ****
  	t = force_fit_type (t, 1,
  			    (overflow | TREE_OVERFLOW (arg0))
  			    && !TYPE_UNSIGNED (type),
! 			    TREE_CONSTANT_OVERFLOW (arg0));
  	break;
        }
  
--- 13014,13020 ----
  	t = force_fit_type (t, 1,
  			    (overflow | TREE_OVERFLOW (arg0))
  			    && !TYPE_UNSIGNED (type),
! 			    false);
  	break;
        }
  
*************** fold_abs_const (tree arg0, tree type)
*** 13088,13095 ****
  				     TREE_INT_CST_HIGH (arg0),
  				     &low, &high);
  	  t = build_int_cst_wide (type, low, high);
! 	  t = force_fit_type (t, -1, overflow | TREE_OVERFLOW (arg0),
! 			      TREE_CONSTANT_OVERFLOW (arg0));
  	}
        break;
  
--- 13059,13065 ----
  				     TREE_INT_CST_HIGH (arg0),
  				     &low, &high);
  	  t = build_int_cst_wide (type, low, high);
! 	  t = force_fit_type (t, -1, overflow | TREE_OVERFLOW (arg0), false);
  	}
        break;
  
*************** fold_not_const (tree arg0, tree type)
*** 13120,13128 ****
    t = build_int_cst_wide (type,
  			  ~ TREE_INT_CST_LOW (arg0),
  			  ~ TREE_INT_CST_HIGH (arg0));
!   t = force_fit_type (t, 0, TREE_OVERFLOW (arg0),
! 		      TREE_CONSTANT_OVERFLOW (arg0));
! 
    return t;
  }
  
--- 13090,13096 ----
    t = build_int_cst_wide (type,
  			  ~ TREE_INT_CST_LOW (arg0),
  			  ~ TREE_INT_CST_HIGH (arg0));
!   t = force_fit_type (t, 0, TREE_OVERFLOW (arg0), false);
    return t;
  }
  
Index: print-tree.c
===================================================================
*** print-tree.c	(revision 120520)
--- print-tree.c	(working copy)
***************
*** 1,6 ****
  /* Prints out tree in human readable form - GCC
     Copyright (C) 1990, 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
!    2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
  
  This file is part of GCC.
  
--- 1,6 ----
  /* Prints out tree in human readable form - GCC
     Copyright (C) 1990, 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
!    2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
  
  This file is part of GCC.
  
*************** print_node_brief (FILE *file, const char
*** 115,121 ****
    /* We might as well always print the value of an integer or real.  */
    if (TREE_CODE (node) == INTEGER_CST)
      {
!       if (TREE_CONSTANT_OVERFLOW (node))
  	fprintf (file, " overflow");
  
        fprintf (file, " ");
--- 115,121 ----
    /* We might as well always print the value of an integer or real.  */
    if (TREE_CODE (node) == INTEGER_CST)
      {
!       if (TREE_OVERFLOW (node))
  	fprintf (file, " overflow");
  
        fprintf (file, " ");
*************** print_node (FILE *file, const char *pref
*** 701,707 ****
        switch (TREE_CODE (node))
  	{
  	case INTEGER_CST:
! 	  if (TREE_CONSTANT_OVERFLOW (node))
  	    fprintf (file, " overflow");
  
  	  fprintf (file, " ");
--- 701,707 ----
        switch (TREE_CODE (node))
  	{
  	case INTEGER_CST:
! 	  if (TREE_OVERFLOW (node))
  	    fprintf (file, " overflow");
  
  	  fprintf (file, " ");
Index: stor-layout.c
===================================================================
*** stor-layout.c	(revision 120520)
--- stor-layout.c	(working copy)
***************
*** 1,6 ****
  /* C-compiler utilities for types and variables storage layout
     Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1996, 1998,
!    1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
     Free Software Foundation, Inc.
  
  This file is part of GCC.
--- 1,6 ----
  /* C-compiler utilities for types and variables storage layout
     Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1996, 1998,
!    1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
     Free Software Foundation, Inc.
  
  This file is part of GCC.
*************** place_field (record_layout_info rli, tre
*** 1195,1201 ****
    if (DECL_SIZE (field) == 0)
      /* Do nothing.  */;
    else if (TREE_CODE (DECL_SIZE (field)) != INTEGER_CST
! 	   || TREE_CONSTANT_OVERFLOW (DECL_SIZE (field)))
      {
        rli->offset
  	= size_binop (PLUS_EXPR, rli->offset,
--- 1195,1201 ----
    if (DECL_SIZE (field) == 0)
      /* Do nothing.  */;
    else if (TREE_CODE (DECL_SIZE (field)) != INTEGER_CST
! 	   || TREE_OVERFLOW (DECL_SIZE (field)))
      {
        rli->offset
  	= size_binop (PLUS_EXPR, rli->offset,
*************** layout_type (tree type)
*** 1821,1827 ****
  	    && TREE_CODE (TYPE_SIZE_UNIT (element)) == INTEGER_CST
  	    /* If TYPE_SIZE_UNIT overflowed, then it is certainly larger than
  	       TYPE_ALIGN_UNIT.  */
! 	    && !TREE_CONSTANT_OVERFLOW (TYPE_SIZE_UNIT (element))
  	    && !integer_zerop (TYPE_SIZE_UNIT (element))
  	    && compare_tree_int (TYPE_SIZE_UNIT (element),
  			  	 TYPE_ALIGN_UNIT (element)) < 0)
--- 1821,1827 ----
  	    && TREE_CODE (TYPE_SIZE_UNIT (element)) == INTEGER_CST
  	    /* If TYPE_SIZE_UNIT overflowed, then it is certainly larger than
  	       TYPE_ALIGN_UNIT.  */
! 	    && !TREE_OVERFLOW (TYPE_SIZE_UNIT (element))
  	    && !integer_zerop (TYPE_SIZE_UNIT (element))
  	    && compare_tree_int (TYPE_SIZE_UNIT (element),
  			  	 TYPE_ALIGN_UNIT (element)) < 0)
Index: tree-chrec.c
===================================================================
*** tree-chrec.c	(revision 120520)
--- tree-chrec.c	(working copy)
***************
*** 1,5 ****
  /* Chains of recurrences.
!    Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
     Contributed by Sebastian Pop <pop@cri.ensmp.fr>
  
  This file is part of GCC.
--- 1,5 ----
  /* Chains of recurrences.
!    Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
     Contributed by Sebastian Pop <pop@cri.ensmp.fr>
  
  This file is part of GCC.
*************** keep_cast:
*** 1293,1302 ****
  
    /* Don't propagate overflows.  */
    if (CONSTANT_CLASS_P (res))
!     {
!       TREE_CONSTANT_OVERFLOW (res) = 0;
!       TREE_OVERFLOW (res) = 0;
!     }
  
    /* But reject constants that don't fit in their type after conversion.
       This can happen if TYPE_MIN_VALUE or TYPE_MAX_VALUE are not the
--- 1293,1299 ----
  
    /* Don't propagate overflows.  */
    if (CONSTANT_CLASS_P (res))
!     TREE_OVERFLOW (res) = 0;
  
    /* But reject constants that don't fit in their type after conversion.
       This can happen if TYPE_MIN_VALUE or TYPE_MAX_VALUE are not the
Index: tree.c
===================================================================
*** tree.c	(revision 120520)
--- tree.c	(working copy)
***************
*** 1,6 ****
  /* Language-independent node constructors for parse phase of GNU compiler.
     Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
!    1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
     Free Software Foundation, Inc.
  
  This file is part of GCC.
--- 1,6 ----
  /* Language-independent node constructors for parse phase of GNU compiler.
     Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
!    1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
     Free Software Foundation, Inc.
  
  This file is part of GCC.
*************** tree
*** 1023,1029 ****
  build_vector (tree type, tree vals)
  {
    tree v = make_node (VECTOR_CST);
!   int over1 = 0, over2 = 0;
    tree link;
  
    TREE_VECTOR_CST_ELTS (v) = vals;
--- 1023,1029 ----
  build_vector (tree type, tree vals)
  {
    tree v = make_node (VECTOR_CST);
!   int over = 0;
    tree link;
  
    TREE_VECTOR_CST_ELTS (v) = vals;
*************** build_vector (tree type, tree vals)
*** 1038,1050 ****
        if (!CONSTANT_CLASS_P (value))
  	continue;
  
!       over1 |= TREE_OVERFLOW (value);
!       over2 |= TREE_CONSTANT_OVERFLOW (value);
      }
  
!   TREE_OVERFLOW (v) = over1;
!   TREE_CONSTANT_OVERFLOW (v) = over2;
! 
    return v;
  }
  
--- 1038,1047 ----
        if (!CONSTANT_CLASS_P (value))
  	continue;
  
!       over |= TREE_OVERFLOW (value);
      }
  
!   TREE_OVERFLOW (v) = over;
    return v;
  }
  
*************** build_real (tree type, REAL_VALUE_TYPE d
*** 1141,1147 ****
  
    TREE_TYPE (v) = type;
    TREE_REAL_CST_PTR (v) = dp;
!   TREE_OVERFLOW (v) = TREE_CONSTANT_OVERFLOW (v) = overflow;
    return v;
  }
  
--- 1138,1144 ----
  
    TREE_TYPE (v) = type;
    TREE_REAL_CST_PTR (v) = dp;
!   TREE_OVERFLOW (v) = overflow;
    return v;
  }
  
*************** build_real_from_int_cst (tree type, tree
*** 1175,1181 ****
    v = build_real (type, real_value_from_int_cst (type, i));
  
    TREE_OVERFLOW (v) |= overflow;
-   TREE_CONSTANT_OVERFLOW (v) |= overflow;
    return v;
  }
  
--- 1172,1177 ----
*************** build_complex (tree type, tree real, tre
*** 1224,1231 ****
    TREE_IMAGPART (t) = imag;
    TREE_TYPE (t) = type ? type : build_complex_type (TREE_TYPE (real));
    TREE_OVERFLOW (t) = TREE_OVERFLOW (real) | TREE_OVERFLOW (imag);
-   TREE_CONSTANT_OVERFLOW (t)
-     = TREE_CONSTANT_OVERFLOW (real) | TREE_CONSTANT_OVERFLOW (imag);
    return t;
  }
  
--- 1220,1225 ----

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH/RFC] Death to TREE_CONSTANT_OVERFLOW
  2007-01-10  3:06 [PATCH/RFC] Death to TREE_CONSTANT_OVERFLOW Roger Sayle
@ 2007-01-10  9:22 ` Richard Guenther
  2007-01-10 19:06   ` Roger Sayle
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Guenther @ 2007-01-10  9:22 UTC (permalink / raw)
  To: Roger Sayle; +Cc: gcc-patches

On 1/10/07, Roger Sayle <roger@eyesopen.com> wrote:
>
> The following pair of patches perform the major steps in obsoleting the
> macro TREE_CONSTANT_OVERFLOW and its need for a bit in expression tree
> nodes.  Currently, GCC maintains two "overflow" bits on each constant
> expression tree node, TREE_OVERFLOW and TREE_CONSTANT_OVERFLOW.  The
> difference in semantics between these two fields has historically been
> used to track whether or not a diagnostic has been emitted by the C/C++
> front-end.  After several years of effort to unify these fields, and with
> the recent constant overflow warning patches by Manuel, we've now reached
> the point that these two fields are completely synonymous, and there's no
> longer any reason for the C front-end to maintain this aspect of state in
> the middle-end's tree representation.  Indeed few middle-end contributors
> fully understood the difference between TREE_CONSTANT_OVERFLOW and
> TREE_OVERFLOW and examination of the source shows they've been used and
> misused interchangeably.
>
> Attached below are two patches, the first is a simple tweak to tree.h that
> makes TREE_CONSTANT_OVERFLOW a synonym for TREE_OVERFLOW.  With this
> change alone, i686-pc-linux-gnu can be fully bootstrapped, all default
> languages including Ada, and regression tested with a top-level "make -k
> check" with no new failures.  This demonstrates/confirms that the
> distinction is no longer necessary, and serves as a "transition state"
> whilst the tree is transitioned such that all uses of
> TREE_CONSTANT_OVERFLOW are replaced with TREE_OVERFLOW.  Once this
> transition is complete, the definition of TREE_CONSTANT_OVERFLOW can be
> completely removed from tree.h.
>
> To start the ball rolling, the second patch below does precisely this for
> all uses of TREE_CONSTANT_OVERFLOW in the middle-end (the main users being
> fold-const.c and builtins.c).  This patch has also been bootstrapped and
> regression tested on i686-pc-linux-gnu, all languages including Ada, on
> top of the first tree.h patch with no new failures.
>
> Rather than commit both patches under my own authority without warning, I
> thought it far more polite to propose these changes here to give folks a
> "heads up", and the opportunity to complain or plan for this transition.
> For the time being TREE_CONSTANT_OVERFLOW will still exist, so pending
> branch merges and tree-ssa optimization passes that refer to it shouldn't
> have a problem.  But ultimately, once all the front-ends have been weaned
> this macro will disappear (possibly even poisoned).
>
> Thoughts, comments or objections?  If there isn't a outcry, I propose to
> commit both patches to mainline in a day or two.  If the C/C++ front-end
> maintainers notice a problem on Plum-Hall or other testsuite not covered
> by the dejagnu testsuite I'm happy to hold-off on this patch, until that
> issue is resolved.  However, I don't expect a problem, as recent
> improvements to our overflow diagnostics have made them better than
> they've ever been.
>
> Ok?

Yay!  Yes ;)

Honestly I rather want to get rid of TREE_OVERFLOW as well... at
least for the middle-end.  We're keeping constants with that flag
set around which for example makes it impossible to assert that
we never record a bound with TREE_OVERFLOW set in VRP (without
just ignoring all them).  (See the (invalid I think now) PR30418).

Thanks,
Richard.

>
> 2007-01-09  Roger Sayle  <roger@eyesopen.com>
>
>         * tree.h (TREE_CONSTANT_OVERFLOW): Obsolete.  For the time being,
>         treat TREE_CONSTANT_OVERFLOW as a synonym of TREE_OVERFLOW.
>
>
> 2007-01-09  Roger Sayle  <roger@eyesopen.com>
>
>         * builtins.c (expand_builtin_pow, expand_builtin_powi,
>         fold_builtin_cabs, fold_builtin_sqrt, fold_builtin_trunc,
>         fold_builtin_floor, fold_builtin_ceil, fold_builtin_round,
>         fold_builtin_int_int_roundingfn, fold_builtin_bitop,
>         fold_builtin_bswap, real_constp, fold_builtin_pow,
>         fold_builtin_powi, fold_builtin_signbit, fold_builtin_copysign,
>         fold_builtin_object_size, do_mpfr_arg1, do_mpfr_arg2,
>         do_mpfr_arg3, do_mpfr_sincos): Replace uses of the macro
>         TREE_CONSTANT_OVERFLOW with TREE_OVERFLOW.
>         * convert.c (convert_to_pointer): Likewise.
>         * expr.c (highest_pow2_factor, expand_expr_real_1): Likewise.
>         * fold-const.c (force_fit_type, fold_negate_expr, int_const_binop,
>         const_binop, fold_convert_const_int_from_int,
>         fold_convert_const_int_from_real,
>         fold_convert_const_real_from_real, sign_bit_p,
>         optimize_minmax_comparison, extract_muldiv_1, fold_div_compare,
>         fold_sign_changed_comparison, fold_unary, fold_comparison,
>         fold_binary, multiple_of_p, tree_Expr_non_zero_p,
>         fold_negate_const, fold_abs_const, fold_not_const): Likewise.
>         * print-tree.c (print_node_brief, print_node): Likewise.
>         * stor-layout.c (place_field, layout_type): Likewise.
>         * tree-chrec.c (keep_cast): Likewise.
>         * tree.c (build_vector, build_real, build_real_from_int_cst,
>         build_complex): Likewise.
>
>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH/RFC] Death to TREE_CONSTANT_OVERFLOW
  2007-01-10  9:22 ` Richard Guenther
@ 2007-01-10 19:06   ` Roger Sayle
  2007-01-10 19:19     ` Richard Guenther
  0 siblings, 1 reply; 4+ messages in thread
From: Roger Sayle @ 2007-01-10 19:06 UTC (permalink / raw)
  To: Richard Guenther; +Cc: gcc-patches

On Wed, January 10, 2007 2:22 am, Richard Guenther wrote:
> On 1/10/07, Roger Sayle <roger@eyesopen.com> wrote:
>> The following pair of patches perform the major steps in obsoleting the
>> macro TREE_CONSTANT_OVERFLOW and its need for a bit in expression tree
>> nodes.
>
> Yay!
> Honestly I rather want to get rid of TREE_OVERFLOW as well... at
> least for the middle-end.

I suspect that getting rid of TREE_OVERFLOW completely may take a while.
Currently it's the only API we have for passing back from the middle-end
and indication that a computation overflowed.  This leads to awkwardness
like your proposal to duplicate int_const_binop so that we can track
overflow on unsigned calculations! :-{

My more immediate goals include (1) restricting TREE_OVERFLOW to
INTEGER_CST nodes (we don't really need them on STRING_CSTs and REAL_CSTs,
but VECTOR_CSTs and COMPLEX_CSTs are tricky), (2) not setting
TREE_OVERFLOW for casts (integer<->integer interconversions), and perhaps
(3) not automatically propagating TREE_OVERFLOW from arguments to results.
This is all contrigent upon some C front-end patches I have to make more
use of "struct c_expr" in the parser.

Roger
--


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH/RFC] Death to TREE_CONSTANT_OVERFLOW
  2007-01-10 19:06   ` Roger Sayle
@ 2007-01-10 19:19     ` Richard Guenther
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Guenther @ 2007-01-10 19:19 UTC (permalink / raw)
  To: Roger Sayle; +Cc: gcc-patches

On 1/10/07, Roger Sayle <roger@eyesopen.com> wrote:
> On Wed, January 10, 2007 2:22 am, Richard Guenther wrote:
> > On 1/10/07, Roger Sayle <roger@eyesopen.com> wrote:
> >> The following pair of patches perform the major steps in obsoleting the
> >> macro TREE_CONSTANT_OVERFLOW and its need for a bit in expression tree
> >> nodes.
> >
> > Yay!
> > Honestly I rather want to get rid of TREE_OVERFLOW as well... at
> > least for the middle-end.
>
> I suspect that getting rid of TREE_OVERFLOW completely may take a while.
> Currently it's the only API we have for passing back from the middle-end
> and indication that a computation overflowed.  This leads to awkwardness
> like your proposal to duplicate int_const_binop so that we can track
> overflow on unsigned calculations! :-{

Dissect, not duplicate - but yeah, life is hard :/

> My more immediate goals include (1) restricting TREE_OVERFLOW to
> INTEGER_CST nodes (we don't really need them on STRING_CSTs and REAL_CSTs,
> but VECTOR_CSTs and COMPLEX_CSTs are tricky), (2) not setting
> TREE_OVERFLOW for casts (integer<->integer interconversions), and perhaps
> (3) not automatically propagating TREE_OVERFLOW from arguments to results.
> This is all contrigent upon some C front-end patches I have to make more
> use of "struct c_expr" in the parser.

From time to time I play with the idea of completely separating frontend
and middle-end trees as they are now by copying files & sed and writing
a translator before going to gimple...  with all the costs involved.  At least
it would allow more independent cleanups of the different ILs.

Richard.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-01-10 19:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-10  3:06 [PATCH/RFC] Death to TREE_CONSTANT_OVERFLOW Roger Sayle
2007-01-10  9:22 ` Richard Guenther
2007-01-10 19:06   ` Roger Sayle
2007-01-10 19:19     ` Richard Guenther

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).