[LoopFlatten] Fix assertion failure
authorRosie Sumpter <rosie.sumpter@arm.com>
Tue, 17 Aug 2021 10:43:34 +0000 (11:43 +0100)
committerRosie Sumpter <rosie.sumpter@arm.com>
Thu, 19 Aug 2021 12:18:57 +0000 (13:18 +0100)
commitd1aa075129a94232bce6d47306f8c719ceef9142
tree7ddc7777cd55c86319ace7b2e3fbd4f7ce139eb1
parente6b1ac85461ac37526fcc3157a15880c4b289b97
[LoopFlatten] Fix assertion failure

There is an assertion failure in computeOverflowForUnsignedMul
(used in checkOverflow) due to the inner and outer trip counts
having different types. This occurs when the IV has been widened,
but the loop components are not successfully rediscovered.
This is fixed by some refactoring of the code in findLoopComponents
which identifies the trip count of the loop.

Differential Revision: https://reviews.llvm.org/D108107
llvm/lib/Transforms/Scalar/LoopFlatten.cpp
llvm/test/Transforms/LoopFlatten/loop-flatten-negative.ll