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] Handle MEM_REF some more in fold_const_aggregate_ref


With some pending LTO patches I noticed we do not ahndle MEM_REF
as the base of ARRAY_REFs in that function.  Fixed as follows,

bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2010-07-14  Richard Guenther  <rguenther@suse.de>

	* tree-ssa-ccp.c (fold_const_aggregate_ref): Handle MEM_REF
	as base of ARRAY_REFs.

Index: gcc/tree-ssa-ccp.c
===================================================================
*** gcc/tree-ssa-ccp.c	(revision 162173)
--- gcc/tree-ssa-ccp.c	(working copy)
*************** fold_const_aggregate_ref (tree t)
*** 1164,1169 ****
--- 1164,1179 ----
        base = TREE_OPERAND (t, 0);
        switch (TREE_CODE (base))
  	{
+ 	case MEM_REF:
+ 	  /* ???  We could handle this case.  */
+ 	  if (!integer_zerop (TREE_OPERAND (base, 1)))
+ 	    return NULL_TREE;
+ 	  base = get_base_address (base);
+ 	  if (!base
+ 	      || TREE_CODE (base) != VAR_DECL)
+ 	    return NULL_TREE;
+ 
+ 	  /* Fallthru.  */
  	case VAR_DECL:
  	  if (!TREE_READONLY (base)
  	      || TREE_CODE (TREE_TYPE (base)) != ARRAY_TYPE


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