we can turn the branch with const condition into a unconditional branch.
With this transformation, we can then run a dead block deletion algorithm to remove
unreachable blocks in the loop.
This is useful as the next time we unswitch this loop, we will have fewer
blocks to duplicate and fewer instructions to remap, etc.
This should also give us a better idea of the real unswitch cost of the
loop (even though we still cant use this information right now).
Additionally, its good for us to clean up as soon as possible in loop unswitch,
otherwise we duplicate a lot of dead code which need to be cleaned up by
later passes, this is suboptimal as this leads to more compilation time.
Note: I have not fixed all the LIT tests yet. There are quite a number of them to FIX.
I will upload again again once I fix them. Would like for people to take a look first
while I work on fixing the tests.
See the comment near the beginning of LoopUnswitch::TryTrivialLoopUnswitch for a description of all the state you aren't updating correctly.
Also, I think you meant "isa<ConstantInt>(BI->getCondition())".