This is the mail archive of the gcc@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: Latent bug in tree-ssa-loop-manip.c:split_loop_exit_edge


Hello,

> With some local changes, I am running into a latent bug in
> split_loop_exit_edge.
> 
> ...
>  for (phi = phi_nodes (dest); phi; phi = TREE_CHAIN (phi))
>     {
>       op_p = PHI_ARG_DEF_PTR_FROM_EDGE (phi, bb->succ);
> 
>       new_name = duplicate_ssa_name (USE_FROM_PTR (op_p), NULL);
> ...
> 
> Not all PHI arguments are guaranteed to be SSA_NAMEs.  What should this
> function do when OP_P is a constant?

I will send the patch once it passes regtesting.

Zdenek

Index: tree-ssa-loop-manip.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-loop-manip.c,v
retrieving revision 2.5
diff -c -3 -p -r2.5 tree-ssa-loop-manip.c
*** tree-ssa-loop-manip.c	9 Sep 2004 07:54:12 -0000	2.5
--- tree-ssa-loop-manip.c	11 Sep 2004 14:26:17 -0000
*************** split_loop_exit_edge (edge exit)
*** 395,411 ****
  {
    basic_block dest = exit->dest;
    basic_block bb = loop_split_edge_with (exit, NULL);
!   tree phi, new_phi, new_name;
    use_operand_p op_p;
  
    for (phi = phi_nodes (dest); phi; phi = TREE_CHAIN (phi))
      {
        op_p = PHI_ARG_DEF_PTR_FROM_EDGE (phi, bb->succ);
  
!       new_name = duplicate_ssa_name (USE_FROM_PTR (op_p), NULL);
        new_phi = create_phi_node (new_name, bb);
        SSA_NAME_DEF_STMT (new_name) = new_phi;
!       add_phi_arg (&new_phi, USE_FROM_PTR (op_p), exit);
        SET_USE (op_p, new_name);
      }
  }
--- 395,420 ----
  {
    basic_block dest = exit->dest;
    basic_block bb = loop_split_edge_with (exit, NULL);
!   tree phi, new_phi, new_name, name;
    use_operand_p op_p;
  
    for (phi = phi_nodes (dest); phi; phi = TREE_CHAIN (phi))
      {
        op_p = PHI_ARG_DEF_PTR_FROM_EDGE (phi, bb->succ);
  
!       name = USE_FROM_PTR (op_p);
! 
!       /* If the argument of the phi node is a constant, we do not need
! 	 to keep it inside loop.  */
!       if (TREE_CODE (name) != SSA_NAME)
! 	continue;
! 
!       /* Otherwise create an auxiliary phi node that will copy the value
! 	 of the ssa name out of the loop.  */
!       new_name = duplicate_ssa_name (name, NULL);
        new_phi = create_phi_node (new_name, bb);
        SSA_NAME_DEF_STMT (new_name) = new_phi;
!       add_phi_arg (&new_phi, name, exit);
        SET_USE (op_p, new_name);
      }
  }


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