This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Bugs in SSA-CCP and SSA-PRE optimizers
- From: Daniel Berlin <dberlin at dberlin dot org>
- To: Steven Bosscher <s dot bosscher at student dot tudelft dot nl>
- Cc: gcc at gcc dot gnu dot org
- Date: Tue, 17 Sep 2002 16:23:42 -0400
- Subject: Re: Bugs in SSA-CCP and SSA-PRE optimizers
On Tuesday, September 17, 2002, at 03:58 PM, Steven Bosscher wrote:
Hello,
Consider:
int main()
{
int bla, foo, bar;
bla = 1;
foo = 2*bla;
bar = 2*bla+1;
goto waffle;
return bar;
waffle:
bla = 1;
return bar;
}
Obviously quite simple to do CCP and PRE on (and DCE but that's not in
CVS yet).
So I tried to compile it and see what the optimized tree looks like. I
applied a patch to dump the optimized tree after the SSA optimizations
are done.
Compiler is this mornings tree-ssa-branch.
Left hand side is: gcc -fdump-tree-all-ssa t.c
Right hand side is:
gcc -fdump-tree-all-ssa -ftree-ssa -ftree-ssa-pre -ftree-ssa-ccp t.c
Stop.
already, you are screwed.
CCP doesn't update the SSA representation, thus, PRE won't have correct
data.
Try them individually, not together, for right now.
diff -y 1/t.c.t10.optimized 3/t.c.t10.optimized
main() main()
{ {
int bla; int bla;
int foo; int foo;
int bar; int bar;
int T.1; int T.1;
> int pretmp.2;
bla = 1; bla = 1;
foo = bla * 2; | foo = pretmp.2 = 1 * 2;
T.1 = bla * 2; | T.1 = pretmp.2;
bar = T.1 + 1; bar = T.1 + 1;
goto waffle; goto waffle;
return bar; return bar;
waffle: waffle:
bla = 1; bla = 1;
return bar; return bar;
} }
Note the redundant assignment to T.1. It seems PRE doesn't kill those
T.[0-9*] variables (both uses and it declarations). We're generating (a
lot of?) useless RTL here.
Also, why is "foo = pretmp.2 = 1 * 2" not folded?
Because i don't call fold on the result?