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] See through ADDR_EXPR for forwprop


This patch enables us to forward-propagate ADDR_EXPRs of the form

alias2.cpp.t21.dce1:
  D.2326_109 = &dX.D.2303.D.2259.domain_m[0].D.2216;
  D.2326_110 = D.2326_109;
  D.2327_111 = &D.2326_110->D.2207;
  this_112 = D.2327_111;
  D.2802_113 = this_112->D.2161.domain_m;

alias2.cpp.t22.forwprop1
  D.2802_113 = dX.D.2303.D.2259.domain_m[0].D.2216.D.2207.D.2161.domain_m;

in one step, instead of waiting for .t75.forwprop3 like
happened in the testcase for PR19626.

Any reason why we should not do this?

Bootstrapped on x86_64-unknown-linux-gnu, regtesting in progress.

Ok for mainline after slush?

Thanks,
Richard.
2005-05-23  Richard Guenther  <rguenth@gcc.gnu.org>

	* tree-ssa-forwprop.c (forward_propagate_addr_expr):
	See through ADDR_EXPR in finding place to propagate into.

Index: tree-ssa-forwprop.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-forwprop.c,v
retrieving revision 2.19
diff -c -3 -p -r2.19 tree-ssa-forwprop.c
*** tree-ssa-forwprop.c	19 May 2005 03:05:40 -0000	2.19
--- tree-ssa-forwprop.c	23 May 2005 11:35:29 -0000
*************** forward_propagate_addr_expr (tree stmt)
*** 558,564 ****
  
    /* Strip away any outer COMPONENT_REF/ARRAY_REF nodes from the LHS.  */
    lhs = TREE_OPERAND (use_stmt, 0);
!   while (TREE_CODE (lhs) == COMPONENT_REF || TREE_CODE (lhs) == ARRAY_REF)
      lhs = TREE_OPERAND (lhs, 0);
  
    /* Now see if the LHS node is an INDIRECT_REF using NAME.  If so, 
--- 558,565 ----
  
    /* Strip away any outer COMPONENT_REF/ARRAY_REF nodes from the LHS.  */
    lhs = TREE_OPERAND (use_stmt, 0);
!   while (TREE_CODE (lhs) == COMPONENT_REF || TREE_CODE (lhs) == ARRAY_REF
! 	 || TREE_CODE (lhs) == ADDR_EXPR)
      lhs = TREE_OPERAND (lhs, 0);
  
    /* Now see if the LHS node is an INDIRECT_REF using NAME.  If so, 
*************** forward_propagate_addr_expr (tree stmt)
*** 589,595 ****
  
    /* Strip away any outer COMPONENT_REF/ARRAY_REF nodes from the RHS.  */
    rhs = TREE_OPERAND (use_stmt, 1);
!   while (TREE_CODE (rhs) == COMPONENT_REF || TREE_CODE (rhs) == ARRAY_REF)
      rhs = TREE_OPERAND (rhs, 0);
  
    /* Now see if the RHS node is an INDIRECT_REF using NAME.  If so, 
--- 590,597 ----
  
    /* Strip away any outer COMPONENT_REF/ARRAY_REF nodes from the RHS.  */
    rhs = TREE_OPERAND (use_stmt, 1);
!   while (TREE_CODE (rhs) == COMPONENT_REF || TREE_CODE (rhs) == ARRAY_REF
! 	 || TREE_CODE (rhs) == ADDR_EXPR)
      rhs = TREE_OPERAND (rhs, 0);
  
    /* Now see if the RHS node is an INDIRECT_REF using NAME.  If so, 

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