* Latent bug in tree-ssa-loop-manip.c:split_loop_exit_edge
@ 2004-09-11 17:01 Diego Novillo
2004-09-11 17:03 ` Zdenek Dvorak
2004-09-12 23:18 ` [patch] " Zdenek Dvorak
0 siblings, 2 replies; 3+ messages in thread
From: Diego Novillo @ 2004-09-11 17:01 UTC (permalink / raw)
To: Zdenek Dvorak; +Cc: gcc
Zdenek,
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?
Thanks. Diego.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Latent bug in tree-ssa-loop-manip.c:split_loop_exit_edge
2004-09-11 17:01 Latent bug in tree-ssa-loop-manip.c:split_loop_exit_edge Diego Novillo
@ 2004-09-11 17:03 ` Zdenek Dvorak
2004-09-12 23:18 ` [patch] " Zdenek Dvorak
1 sibling, 0 replies; 3+ messages in thread
From: Zdenek Dvorak @ 2004-09-11 17:03 UTC (permalink / raw)
To: Diego Novillo; +Cc: gcc
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);
}
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* [patch] Re: Latent bug in tree-ssa-loop-manip.c:split_loop_exit_edge
2004-09-11 17:01 Latent bug in tree-ssa-loop-manip.c:split_loop_exit_edge Diego Novillo
2004-09-11 17:03 ` Zdenek Dvorak
@ 2004-09-12 23:18 ` Zdenek Dvorak
1 sibling, 0 replies; 3+ messages in thread
From: Zdenek Dvorak @ 2004-09-12 23:18 UTC (permalink / raw)
To: Diego Novillo; +Cc: gcc, gcc-patches
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?
this patch fixes the function -- we do not need to do anything when
operand is a constant, since moving it out of the loop cannot violate
loop closed ssa form.
Bootstrapped & regtested on i686.
Zdenek
* tree-ssa-loop-manip.c (split_loop_exit_edge): Handle non-ssaname
arguments of the phi nodes correctly.
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);
}
}
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-09-12 19:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-11 17:01 Latent bug in tree-ssa-loop-manip.c:split_loop_exit_edge Diego Novillo
2004-09-11 17:03 ` Zdenek Dvorak
2004-09-12 23:18 ` [patch] " Zdenek Dvorak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).