[LoopUnroll] Clamp unroll count to MaxTripCount
authorNikita Popov <nikita.ppv@gmail.com>
Sat, 5 Jun 2021 08:49:51 +0000 (10:49 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Mon, 7 Jun 2021 19:08:42 +0000 (21:08 +0200)
commit8fdd7c2ff16da370e28ef1b22e400d57a541484f
treeca339a4206602a2273fb4c7dbb15729eb85264cb
parentd70e1f12765fd6bb644ffb561dff9a31c522308e
[LoopUnroll] Clamp unroll count to MaxTripCount

Unrolling with more iterations than MaxTripCount is pointless, as
those iterations can never be executed. As such, we clamp ULO.Count
to MaxTripCount if it is known. This means we no longer need to
consider iterations after MaxTripCount for exit folding, and the
CompletelyUnroll flag becomes independent of ULO.TripCount.

Differential Revision: https://reviews.llvm.org/D103748
llvm/lib/Transforms/Utils/LoopUnroll.cpp
llvm/test/Transforms/LoopUnroll/multiple-exits.ll
llvm/test/Transforms/LoopUnroll/nonlatchcondbr.ll
llvm/test/Transforms/LoopUnroll/runtime-loop5.ll
llvm/test/Transforms/LoopUnroll/runtime-small-upperbound.ll