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]

[tree-ssa] Folder fix


Whee.  One of my pending changes results in the optimizers seeing more
expressions and as it turns out exposed a latent bug in the folder.
Specifically it didn't verify that the incoming operand was a suitable
constant before trying to extract and manipulate its constant value.



	* fold-const.c (nondestructive_fold_unary_to_constant: For BIT_NOT_EXPR
	make sure OP0 is a suitable constant before trying to fold it.

Index: fold-const.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fold-const.c,v
retrieving revision 1.213.2.35
diff -c -3 -p -r1.213.2.35 fold-const.c
*** fold-const.c	5 Jul 2003 17:46:05 -0000	1.213.2.35
--- fold-const.c	8 Jul 2003 07:10:48 -0000
*************** nondestructive_fold_unary_to_constant (c
*** 5626,5637 ****
  	return NULL_TREE;
  
      case BIT_NOT_EXPR:
!       t = build_int_2 (~ TREE_INT_CST_LOW (op0), ~ TREE_INT_CST_HIGH (op0));
!       TREE_TYPE (t) = type;
!       force_fit_type (t, 0);
!       TREE_OVERFLOW (t) = TREE_OVERFLOW (op0);
!       TREE_CONSTANT_OVERFLOW (t) = TREE_CONSTANT_OVERFLOW (op0);
!       return t;
  
      case REALPART_EXPR:
        if (TREE_CODE (op0) == COMPLEX_CST)
--- 5626,5642 ----
  	return NULL_TREE;
  
      case BIT_NOT_EXPR:
!       if (TREE_CODE (op0) == INTEGER_CST || TREE_CODE (op0) == REAL_CST)
! 	{
! 	  t = build_int_2 (~ TREE_INT_CST_LOW (op0), ~ TREE_INT_CST_HIGH (op0));
! 	  TREE_TYPE (t) = type;
! 	  force_fit_type (t, 0);
! 	  TREE_OVERFLOW (t) = TREE_OVERFLOW (op0);
! 	  TREE_CONSTANT_OVERFLOW (t) = TREE_CONSTANT_OVERFLOW (op0);
! 	  return t;
! 	}
!       else
! 	return NULL_TREE;
  
      case REALPART_EXPR:
        if (TREE_CODE (op0) == COMPLEX_CST)



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