This is the mail archive of the gcc-patches@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: advanced value range propagation for tree-ssa


zhouyi zhou wrote:
High, Currently gcc can optimize following program by threading a block:
int
fn(int s, int w) {
int i;


i = 2;

  if (s)
   i = 1;

  if (s)
   printf("%d\n", i);

  return 0;
}

  While it cannot handle programs of following kind:
int
fn(int s, int w) {
  int i;

i = 2;

  if (s)
   i = 1;

  if (w)
   goto out1;

  if (s)
   printf("%d\n", i);

out1:
  return 0;
}

The advanced value range propagation:
http://wiki.freebsd.org/ZhouyiZHOU?action=AttachFile&do=get&target=avrp.patch

nicely handles the above case

2 (if s)
/ \
8 3
\ |
\__ 4----
/ 5(if s) / \
6 10


The advanced value range propagation 1) identify the candidate basic block pairs by recurively matching the dom son and dom parent (in our case block 5 and block 2 are
selected)
2) identiy the threadable edge pairs:
here edge pair 8-4 and 5-6, 3-4 and 5-10 are selected
3) thread the edges (duplicate the basic blocks between)
2
/ \
8 3
| \
4'- 4''-
| |
5' 5''
/ |
6 10


The patch is being compiled and bootstraped on i686-linux m-32.
and passed most of regression test by make -k check (the not passed tests
 are caused the wrong configuration of my machine like libgmp and libmpfr)

The patch is rudimentary and very dirty written currently, I will clean it in the future
Kenny outlined an algorithm which should handle these cases rather easily at the GCC summit a few years back. You might ask him for the slides from his opening presentation as they included the outline of the algorithm.

I did an implementation to compare it against the current edge threading code and while it didn't stack up too well, there were a few cases where Kenny's algorithm would find something optimizable, but the current threader would not. Your example is one of those cases.

Implementation was fairly easy -- it might be easier to work from Kenny's algorithm than cleaning up your own.


Jeff



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