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]

Fix random hashing problems with ARRAY_REF and COMPONENT_REF


This should fix the random comparison problems that have been popping up
in various contexts since I added the new operands for ARRAY_REF and
COMPONENT_REF.  Sorry for the delay in getting this in, but I wanted to
be sure it was really the source of the problems, which I never reproduced.

Tested on x86_64-linux.

2004-07-20  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>

	* fold-const.c (operand_equal_p): Temporarily support NULL args.
	(operand_equal_p, case ARRAY_REF): Compare args 2 and 3.
	(operand_equal_p, case COMPONENT_REF): Likewise, for arg 2.

*** fold-const.c	20 Jul 2004 23:02:33 -0000	1.426
--- fold-const.c	21 Jul 2004 01:18:11 -0000
*************** int
*** 2349,2354 ****
  operand_equal_p (tree arg0, tree arg1, unsigned int flags)
  {
    /* If either is ERROR_MARK, they aren't equal.  */
!   if (TREE_CODE (arg0) == ERROR_MARK || TREE_CODE (arg1) == ERROR_MARK)
      return 0;
  
--- 2349,2363 ----
  operand_equal_p (tree arg0, tree arg1, unsigned int flags)
  {
+   /* If one is specified and the other isn't, they aren't equal and if
+      neither is specified, they are.
+ 
+      ??? This is temporary and is meant only to handle the cases of the
+      optional operands for COMPONENT_REF and ARRAY_REF.  */
+   if ((arg0 && !arg1) || (!arg0 && arg1))
+     return 0;
+   else if (!arg0 && !arg1)
+     return 1;
    /* If either is ERROR_MARK, they aren't equal.  */
!   else if (TREE_CODE (arg0) == ERROR_MARK || TREE_CODE (arg1) == ERROR_MARK)
      return 0;
  
*************** operand_equal_p (tree arg0, tree arg1, u
*** 2484,2488 ****
  				  TREE_OPERAND (arg1, 0), flags);
  
- 	case COMPONENT_REF:
  	case ARRAY_REF:
  	case ARRAY_RANGE_REF:
--- 2493,2496 ----
*************** operand_equal_p (tree arg0, tree arg1, u
*** 2490,2494 ****
  				   TREE_OPERAND (arg1, 0), flags)
  		  && operand_equal_p (TREE_OPERAND (arg0, 1),
! 				      TREE_OPERAND (arg1, 1), flags));
  
  	case BIT_FIELD_REF:
--- 2498,2516 ----
  				   TREE_OPERAND (arg1, 0), flags)
  		  && operand_equal_p (TREE_OPERAND (arg0, 1),
! 				      TREE_OPERAND (arg1, 1), flags)
! 		  && operand_equal_p (TREE_OPERAND (arg0, 2),
! 				      TREE_OPERAND (arg1, 2), flags)
! 		  && operand_equal_p (TREE_OPERAND (arg0, 3),
! 				      TREE_OPERAND (arg1, 3), flags));
! 
! 
! 	case COMPONENT_REF:
! 	  return (operand_equal_p (TREE_OPERAND (arg0, 0),
! 				   TREE_OPERAND (arg1, 0), flags)
! 		  && operand_equal_p (TREE_OPERAND (arg0, 1),
! 				      TREE_OPERAND (arg1, 1), flags)
! 		  && operand_equal_p (TREE_OPERAND (arg0, 2),
! 				      TREE_OPERAND (arg1, 2), flags));
! 
  
  	case BIT_FIELD_REF:


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