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