[PM/LoopUnswitch] Fix a bug in the loop block set formation of the new
authorChandler Carruth <chandlerc@gmail.com>
Tue, 24 Apr 2018 10:33:08 +0000 (10:33 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Tue, 24 Apr 2018 10:33:08 +0000 (10:33 +0000)
commit43acdb35bc94ed63b2ebd264aebfa2a757d5d545
treed4945de8c4a756c8774fb5d1f271591e507c9e5d
parente2bfcd6394e18e4cf04bc367758c4d667f43c97b
[PM/LoopUnswitch] Fix a bug in the loop block set formation of the new
loop unswitch.

This code incorrectly added the header to the loop block set early. As
a consequence we would incorrectly conclude that a nested loop body had
already been visited when the header of the outer loop was the preheader
of the nested loop. In retrospect, adding the header eagerly doesn't
really make sense. It seems nicer to let the cycle be formed naturally.
This will catch crazy bugs in the CFG reconstruction where we can't
correctly form the cycle earlier rather than later, and makes the rest
of the logic just fall out.

I've also added various asserts that make these issues *much* easier to
debug.

llvm-svn: 330707
llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch.ll