[IndVarSimplify] Simplify code using preheader assumption
authorPhilip Reames <listmail@philipreames.com>
Tue, 31 Oct 2017 05:16:46 +0000 (05:16 +0000)
committerPhilip Reames <listmail@philipreames.com>
Tue, 31 Oct 2017 05:16:46 +0000 (05:16 +0000)
commit59bf1e0548460364e96f168bef5fcd66a98d54cb
tree755f7c3b12fadce6442f28506c9344f65ae01c6a
parent488ec975bb418cc3fd230a9acdfdb1effc61670e
[IndVarSimplify] Simplify code using preheader assumption

As noted in the nice block comment, the previous code didn't actually handle multi-entry loops correctly, it just assumed SCEV didn't analyze such loops.  Given SCEV has comments to the contrary, that seems a bit suspect.  More importantly, the pass actually requires loopsimplify form which ensures a loop-preheader is available.  Remove the excessive generaility and shorten the code greatly.

Note that we do successfully analyze many multi-entry loops, but we do so by converting them to single entry loops.  See the added test case.

llvm-svn: 316976
llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
llvm/test/Transforms/IndVarSimplify/loop-invariant-conditions.ll