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]

Re: [PATCH] See through ADDR_EXPR for forwprop


On Thu, 2005-05-26 at 16:39 +0200, Richard Guenther wrote:
>  
> > I'm pretty sure you can't have an ADDR_EXPR on the LHS, so I suspect
> > checking for it is just a tiny waste of time.  I'm going to rebootstrap
> > and retest with the first hunk removed.
> 
> Ok, I only had this for completeness.  I'll need to learn more of what
> exactly is gimple and what not.
It's more a question of what makes sense vs what is gimple in this
case :-)  You can't change the address of an object, which is in
effect what you'd be trying to do if an ADDR_EXPR as on the LHS of
an assignment.

Anyway, I've bootstrapped and re-run the testsuite with just the
change to "see through" ADDR_EXPRs in the RHS of the use statement.
All is well and good.

I've attached the actual patch I installed.

Thanks,
Jeff
Index: tree-ssa-forwprop.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-forwprop.c,v
retrieving revision 2.20
diff -c -p -r2.20 tree-ssa-forwprop.c
*** tree-ssa-forwprop.c	24 May 2005 02:53:58 -0000	2.20
--- tree-ssa-forwprop.c	26 May 2005 17:43:37 -0000
*************** forward_propagate_addr_expr (tree stmt)
*** 560,566 ****
    if (bb_for_stmt (use_stmt)->loop_depth > stmt_loop_depth)
      return false;
  
!   /* 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);
--- 560,567 ----
    if (bb_for_stmt (use_stmt)->loop_depth > stmt_loop_depth)
      return false;
  
!   /* Strip away any outer COMPONENT_REF/ARRAY_REF nodes from the LHS. 
!      ADDR_EXPR will not appear on the LHS.  */
    lhs = TREE_OPERAND (use_stmt, 0);
    while (TREE_CODE (lhs) == COMPONENT_REF || TREE_CODE (lhs) == ARRAY_REF)
      lhs = TREE_OPERAND (lhs, 0);
*************** forward_propagate_addr_expr (tree stmt)
*** 591,599 ****
        return true;
      }
  
!   /* 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, 
--- 592,603 ----
        return true;
      }
  
!   /* Strip away any outer COMPONENT_REF, ARRAY_REF or ADDR_EXPR
!      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]