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]

[PATCH] Fix PR39824


This fixes an ICE during CCP.  CCP propagates constant addresses
independent of their type, so places dereferencing it must check
for compatibility.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.
Scheduled for a 4.4 backport.

Richard.

2009-04-22  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/39824
	* tree-ssa-ccp.c (fold_const_aggregate_ref): For INDIRECT_REFs
	make sure the types are compatible.

	* gcc.c-torture/compile/pr39824.c: New testcase.

Index: gcc/tree-ssa-ccp.c
===================================================================
*** gcc/tree-ssa-ccp.c	(revision 146568)
--- gcc/tree-ssa-ccp.c	(working copy)
*************** fold_const_aggregate_ref (tree t)
*** 1329,1335 ****
  	if (TREE_CODE (base) == SSA_NAME
  	    && (value = get_value (base))
  	    && value->lattice_val == CONSTANT
! 	    && TREE_CODE (value->value) == ADDR_EXPR)
  	  return fold_const_aggregate_ref (TREE_OPERAND (value->value, 0));
  	break;
        }
--- 1329,1337 ----
  	if (TREE_CODE (base) == SSA_NAME
  	    && (value = get_value (base))
  	    && value->lattice_val == CONSTANT
! 	    && TREE_CODE (value->value) == ADDR_EXPR
! 	    && useless_type_conversion_p (TREE_TYPE (t),
! 					  TREE_TYPE (TREE_TYPE (value->value))))
  	  return fold_const_aggregate_ref (TREE_OPERAND (value->value, 0));
  	break;
        }
Index: gcc/testsuite/gcc.c-torture/compile/pr39824.c
===================================================================
*** gcc/testsuite/gcc.c-torture/compile/pr39824.c	(revision 0)
--- gcc/testsuite/gcc.c-torture/compile/pr39824.c	(revision 0)
***************
*** 0 ****
--- 1,26 ----
+ static const double internalEndianMagic = 7.949928895127363e-275;
+ static const unsigned char ieee_754_mantissa_mask[] = { 0x00, 0x0F, 0xFF, 0xFF,
+     0xFF, 0xFF, 0xFF, 0xFF };
+ static inline int 
+ trio_isnan (double number)
+ {
+   int has_mantissa = 0;
+   unsigned int i;
+   unsigned char current;
+   for (i = 0; i < (unsigned int)sizeof(double); i++)
+     {
+       current = ((unsigned char *)&number)[(((unsigned char
+ 					      *)&internalEndianMagic)[7-(i)])];
+       has_mantissa |= (current & ieee_754_mantissa_mask[i]);
+     }
+   return has_mantissa;
+ }
+ void
+ xmlXPathEqualNodeSetFloat(int nodeNr, double v)
+ {
+   int i;
+   for (i=0; i<nodeNr; i++)
+     if (!trio_isnan(v))
+       break;
+ }
+ 


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