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][mem-ref2] No longer fold constant component refs


It has served quite well for initial testing.  Now it interferes
with the concept of minimal transition of INDIRECT_REFs.  Thus,
disabled again.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied
to the branch.

Richard.

2010-03-24  Richard Guenther  <rguenther@suse.de>

	* tree.c (recompute_tree_invariant_for_addr_expr): Handle MEM_REF.
	* tree-ssa-sccvn.c (copy_reference_ops_from_ref): Re-instantiate
	code handling ALIGN_INDIRECT_REF and MISALIGNED_INDIRECT_REF.
	* tree-ssa-ccp.c (maybe_fold_reference): Drop code folding
	constant-offset component references into the MEM_REF constant
	offset.

Index: gcc/tree.c
===================================================================
*** gcc/tree.c	(revision 157630)
--- gcc/tree.c	(working copy)
*************** do { tree _node = (NODE); \
*** 3522,3528 ****
       address is constant too.  If it's a decl, its address is constant if the
       decl is static.  Everything else is not constant and, furthermore,
       taking the address of a volatile variable is not volatile.  */
!   if (TREE_CODE (node) == INDIRECT_REF)
      UPDATE_FLAGS (TREE_OPERAND (node, 0));
    else if (CONSTANT_CLASS_P (node))
      ;
--- 3522,3529 ----
       address is constant too.  If it's a decl, its address is constant if the
       decl is static.  Everything else is not constant and, furthermore,
       taking the address of a volatile variable is not volatile.  */
!   if (TREE_CODE (node) == INDIRECT_REF
!       || TREE_CODE (node) == MEM_REF)
      UPDATE_FLAGS (TREE_OPERAND (node, 0));
    else if (CONSTANT_CLASS_P (node))
      ;
Index: gcc/tree-ssa-sccvn.c
===================================================================
*** gcc/tree-ssa-sccvn.c	(revision 157694)
--- gcc/tree-ssa-sccvn.c	(working copy)
*************** copy_reference_ops_from_ref (tree ref, V
*** 528,533 ****
--- 528,540 ----
  
        switch (temp.opcode)
  	{
+ 	case ALIGN_INDIRECT_REF:
+ 	  /* The only operand is the address, which gets its own
+ 	     vn_reference_op_s structure.  */
+ 	    break;
+ 	case MISALIGNED_INDIRECT_REF:
+ 	  temp.op0 = TREE_OPERAND (ref, 1);
+ 	  break;
  	case MEM_REF:
  	  /* The base address gets its own vn_reference_op_s structure.  */
  	  temp.op0 = TREE_OPERAND (ref, 1);
Index: gcc/tree-ssa-ccp.c
===================================================================
*** gcc/tree-ssa-ccp.c	(revision 157694)
--- gcc/tree-ssa-ccp.c	(working copy)
*************** maybe_fold_reference (tree expr, bool is
*** 2580,2613 ****
  	}
      }
  
-   /* Strip constant-offset component refs.  */
-   if (TREE_CODE (*t) == MEM_REF
-       && handled_component_p (expr)
-       /* We can't properly expand these.  */
-       && !((TREE_CODE (expr) == COMPONENT_REF
- 	    && DECL_BIT_FIELD (TREE_OPERAND (expr, 1)))
- 	   || TREE_CODE (expr) == BIT_FIELD_REF))
-     {
-       tree base;
-       HOST_WIDE_INT offset;
-       base = get_addr_base_and_offset (expr, &offset);
-       if (base
- 	  && offset % BITS_PER_UNIT == 0)
- 	{
- 	  if (base == *t)
- 	    return build2 (MEM_REF, TREE_TYPE (expr),
- 			   TREE_OPERAND (*t, 0),
- 			   int_const_binop (PLUS_EXPR,
- 					    TREE_OPERAND (*t, 1),
- 					    build_int_cst (TREE_TYPE (TREE_OPERAND (*t, 1)), offset / BITS_PER_UNIT), 0));
- 	  else if (TREE_CODE (TREE_OPERAND (*t, 0)) == ADDR_EXPR
- 		   && base == TREE_OPERAND (TREE_OPERAND (*t, 0), 0))
- 	    return build2 (MEM_REF, TREE_TYPE (expr),
- 			   TREE_OPERAND (*t, 0),
- 			   build_int_cst (TREE_TYPE (TREE_OPERAND (*t, 1)), offset / BITS_PER_UNIT));
- 	}
-     }
- 
    return NULL_TREE;
  }
  
--- 2580,2585 ----


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