[LLVMdev] A small pass to constant fold branch conditions in destination blocks

Frits van Bommel fvbommel at gmail.com
Mon Feb 7 12:16:12 PST 2011


On Mon, Feb 7, 2011 at 8:54 PM, Duncan Sands <baldrick at free.fr> wrote:
> Here is a new and improved version that also does the following: if the
> condition for a conditional branch has the form "A && B" then A, B and the
> condition are all replaced with "true" in the true destination (similarly
> for || conditions in the false destination).  Also, if the condition has
> the form "X == Y" then X is replaced by Y everywhere in the true destination
> (likewise if it is "X != Y" then X is replaced by Y everywhere in the false
> destination).  Completely untested for correctness!

I also had a try at this, integrating it with the existing correlated
value propagation pass. See
<http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20110207/116167.html>.

I haven't tried if it provides all of the extra things this latest
version does though. (It probably doesn't handle the 'X == Y' case
where neither is a constant)

My version has some tests and passes 'make check-all'.

> Scheduling this pass after -correlated-propagation results for example in
> 5759 lines of bitcode being removed from 403.gcc.

I didn't gather any statistics on it though.




More information about the llvm-dev mailing list