Loop unrolling is usually performed against an exit for which additional information is known, such as a trip count, trip multiple or runtime-enforced trip multiple. This exit receives special treatment, because it can be folded on some or all iterations.
Currently, this exit is not explicitly provided to the unrolling implementation. Instead it assumes that this must be either the unique exit, or the latch exit. For D102635 (where the latch is non-exiting) this results in missed folding opportunities, because unrolling doesn't know which exit the trip count refers to. For D102982 (where the latch can be exiting) it results in miscompiles, because it assumes the wrong exit.
This patch addresses the problem by explicitly providing the ExitingBlock to unrolling. Currently, this shouldn't have any effect, but would have an effect in conjunction with D102635/D102982.
clang-tidy: warning: invalid case style for function 'UnrollLoop' [readability-identifier-naming]
not useful