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]

[Committed] Minor incremental TREE_OVERFLOW clean-up


The following patch is another small step towards the goal of cleaning
up TREE_OVERFLOW usage in the middle-end.  The aim is that overflow is
primarily a front-end attribute, that is mostly ignored by the middle-end,
except in the obvious important case where applying a transformation at
compile-time generates a result that has to be truncated to fit a type,
which would lead to incorrect behavior.  In this model, TREE_OVERFLOW
should primarily only be checked after operations, to test whether the
result is valid.  Other than this the middle-end should preserve the
overflow bits for the benefit of the front-end, but they shouldn't
affect the operation of code.  [Ideally, there should be no need for
TREE_OVERFLOW to be recorded in LTO's on-disk representation].

All sounds reasonable in theory.

This patch removes some now deprecated uses of TREE_CONSTANT_OVERFLOW
from the middle-end, specifically from operand_equal_p in fold-const.c.
Much like in RTL, two constant expressions should be considered equivalent
if their values match, independent of their overflow history.

The following patch has been tested on i686-pc-linux-gnu with a full
"make bootstrap", all default languages including Ada, and regression
tested with a top-level "make -k check" with no new failures.

Committed to mainline as revision 118685.  Let me know if this breaks
anything.


2006-11-10  Roger Sayle  <roger@eyesopen.com>

	* fold-const.c (operand_equal_p) <INTEGER_CST, REAL_CST, VECTOR_CST>:
	Don't check for TREE_CONSTANT_OVERFLOW when comparing constants.


Index: fold-const.c
===================================================================
*** fold-const.c	(revision 118472)
--- fold-const.c	(working copy)
*************** operand_equal_p (tree arg0, tree arg1, u
*** 2544,2567 ****
      switch (TREE_CODE (arg0))
        {
        case INTEGER_CST:
! 	return (! TREE_CONSTANT_OVERFLOW (arg0)
! 		&& ! TREE_CONSTANT_OVERFLOW (arg1)
! 		&& tree_int_cst_equal (arg0, arg1));

        case REAL_CST:
! 	return (! TREE_CONSTANT_OVERFLOW (arg0)
! 		&& ! TREE_CONSTANT_OVERFLOW (arg1)
! 		&& REAL_VALUES_IDENTICAL (TREE_REAL_CST (arg0),
! 					  TREE_REAL_CST (arg1)));

        case VECTOR_CST:
  	{
  	  tree v1, v2;

- 	  if (TREE_CONSTANT_OVERFLOW (arg0)
- 	      || TREE_CONSTANT_OVERFLOW (arg1))
- 	    return 0;
-
  	  v1 = TREE_VECTOR_CST_ELTS (arg0);
  	  v2 = TREE_VECTOR_CST_ELTS (arg1);
  	  while (v1 && v2)
--- 2544,2559 ----
      switch (TREE_CODE (arg0))
        {
        case INTEGER_CST:
! 	return tree_int_cst_equal (arg0, arg1);

        case REAL_CST:
! 	return REAL_VALUES_IDENTICAL (TREE_REAL_CST (arg0),
! 				      TREE_REAL_CST (arg1));

        case VECTOR_CST:
  	{
  	  tree v1, v2;

  	  v1 = TREE_VECTOR_CST_ELTS (arg0);
  	  v2 = TREE_VECTOR_CST_ELTS (arg1);
  	  while (v1 && v2)


Roger
--


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