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: 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?


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