This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Don't require TREE_OVERFLOW in int_fits_type_p
- From: Roger Sayle <roger at eyesopen dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 29 Dec 2004 19:03:19 -0700 (MST)
- Subject: [PATCH] Don't require TREE_OVERFLOW in int_fits_type_p
The following patch tweaks int_fits_type_p to avoid testing the
result of force_fit_type for TREE_OVERFLOW, but instead to compare
the result's value with the original constant value. This is the
same logic as currently used in force_fits_type to determine whether
to set TREE_OVERFLOW, so there's currently no change in functionality.
However, this moves the middle-end away from using/relying on the
TREE_OVERFLOW and TREE_CONSTANT_OVERFLOW flags, which are the source
of several PRs (including 4.0 regressions).
Decoupling this functionality, should prevent changes to when/if we
set TREE_OVERFLOW in force_fit_type from affecting int_fits_type_p.
The following patch has been tested on i686-pc-linux-gnu with a
full "make bootstrap", all default languages, and regression tested
with a top-level "make -k check" with no new failures.
Ok for mainline?
2004-12-29 Roger Sayle <roger@eyesopen.com>
* tree.c (int_fits_type_p): Compare the result of force_fit_type
with the original constant rather than require TREE_OVERFLOW.
Index: tree.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.c,v
retrieving revision 1.457
diff -c -3 -p -r1.457 tree.c
*** tree.c 17 Dec 2004 08:17:01 -0000 1.457
--- tree.c 29 Dec 2004 21:13:18 -0000
*************** int_fits_type_p (tree c, tree type)
*** 4914,4923 ****
/* Or to force_fit_type, if nothing else. */
else
{
! c = copy_node (c);
! TREE_TYPE (c) = type;
! c = force_fit_type (c, -1, false, false);
! return !TREE_OVERFLOW (c);
}
}
--- 4914,4924 ----
/* Or to force_fit_type, if nothing else. */
else
{
! tree n = copy_node (c);
! TREE_TYPE (n) = type;
! n = force_fit_type (n, -1, false, false);
! return TREE_INT_CST_HIGH (n) == TREE_INT_CST_HIGH (c)
! && TREE_INT_CST_LOW (n) == TREE_INT_CST_LOW (c);
}
}
Roger
--