* [tree-ssa] moving phi nodes?
@ 2003-11-16 12:29 Richard Henderson
2003-11-17 16:55 ` law
2004-01-15 18:46 ` law
0 siblings, 2 replies; 3+ messages in thread
From: Richard Henderson @ 2003-11-16 12:29 UTC (permalink / raw)
To: gcc
One jump threading case that we're currently missing, sorely,
is of the form:
int foo(int p, int q)
{
int i = 0;
if (p)
i = q;
if (i != 0)
bar ();
return i;
}
From the t28.dce2 dump:
# BLOCK 0
# PRED: ENTRY (fallthru,exec)
if (p_3 != 0) goto <Uc910>; else goto <Uc984>;
# SUCC: 2 (false,exec) 1 (true,exec)
# BLOCK 1
# PRED: 0 (true,exec)
<Uc910>:;
# SUCC: 2 (fallthru,exec)
# BLOCK 2
# PRED: 0 (false,exec) 1 (fallthru,exec)
# i_1 = PHI <0(0), q_4(1)>;
<Uc984>:;
if (i_1 != 0) goto <Uc9f8>; else goto <Uca6c>;
# SUCC: 4 (false,exec) 3 (true,exec)
# BLOCK 3
# PRED: 2 (true,exec)
<Uc9f8>:;
bar ();
# SUCC: 4 (fallthru,exec)
# BLOCK 4
# PRED: 2 (false,exec) 3 (fallthru,exec)
<Uca6c>:;
return i_1;
# SUCC: EXIT
We really should be threading the edge BB0->BB4, since it is known
that I == 0 when incoming to block 2. Except if we do this, we need
to move the PHI node for I:
# BLOCK 0
# PRED: ENTRY (fallthru,exec)
if (p_3 != 0) goto <Uc910>; else goto <Uca6c>;
# SUCC: 4 (false,exec) 1 (true,exec)
# BLOCK 1
# PRED: 0 (true,exec)
<Uc910>:;
# SUCC: 2 (fallthru,exec)
# BLOCK 2
# PRED: 1 (fallthru,exec)
<Uc984>:;
if (q_4 != 0) goto <Uc9f8>; else goto <Uca6c>;
# SUCC: 4 (false,exec) 3 (true,exec)
# BLOCK 3
# PRED: 2 (true,exec)
<Uc9f8>:;
bar ();
# SUCC: 4 (fallthru,exec)
# BLOCK 4
# PRED: 0 (false,exec) 2 (false,exec) 3 (fallthru,exec)
# i_1 = PHI <0(0), 0(2), q_4(3)>;
<Uca6c>:;
return i_1;
# SUCC: EXIT
Moving the PHI node is non-trivial. Anyone know of a way to do it that
doesn't require just dropping all the SSA names and starting over? Do
we have any other gimple pass planned or desired that would take care
of this as a side effect?
Incidentally, this optimization is performed by the rtl .14.bypass
gcse pass.
r~
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [tree-ssa] moving phi nodes?
2003-11-16 12:29 [tree-ssa] moving phi nodes? Richard Henderson
@ 2003-11-17 16:55 ` law
2004-01-15 18:46 ` law
1 sibling, 0 replies; 3+ messages in thread
From: law @ 2003-11-17 16:55 UTC (permalink / raw)
To: Richard Henderson; +Cc: gcc
In message <20031116062517.GA2111@redhat.com>, Richard Henderson writes:
>One jump threading case that we're currently missing, sorely,
>is of the form:
>
>int foo(int p, int q)
>{
> int i = 0;
> if (p)
> i = q;
> if (i != 0)
> bar ();
> return i;
>}
[ ... ]
>Moving the PHI node is non-trivial. Anyone know of a way to do it that
>doesn't require just dropping all the SSA names and starting over? Do
>we have any other gimple pass planned or desired that would take care
>of this as a side effect?
>
>Incidentally, this optimization is performed by the rtl .14.bypass
>gcse pass.
I would expect this to be caught by the jump threading improvements I'm
working on. Maybe not the first couple iterations, but it's the kind of
thing I do expect to handle.
Jeff
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [tree-ssa] moving phi nodes?
2003-11-16 12:29 [tree-ssa] moving phi nodes? Richard Henderson
2003-11-17 16:55 ` law
@ 2004-01-15 18:46 ` law
1 sibling, 0 replies; 3+ messages in thread
From: law @ 2004-01-15 18:46 UTC (permalink / raw)
To: Richard Henderson; +Cc: gcc
In message <20031116062517.GA2111@redhat.com>, Richard Henderson writes:
>One jump threading case that we're currently missing, sorely,
>is of the form:
>
>int foo(int p, int q)
>{
> int i = 0;
> if (p)
> i = q;
> if (i != 0)
> bar ();
> return i;
>}
>
>From the t28.dce2 dump:
[ ... ]
FWIW, I just checked in an improvement to the dominator optimizer which
should optimize this case.
jeff
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-01-15 18:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-16 12:29 [tree-ssa] moving phi nodes? Richard Henderson
2003-11-17 16:55 ` law
2004-01-15 18:46 ` law
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).