[LoopUnroll] Freeze tripcount rather than condition
authorNikita Popov <npopov@redhat.com>
Wed, 18 May 2022 15:09:36 +0000 (17:09 +0200)
committerNikita Popov <npopov@redhat.com>
Tue, 24 May 2022 07:42:39 +0000 (09:42 +0200)
commit81c648a3d909cf0c1c1c635309f35b93d07307d1
tree898571b5b8aa178e91b0114e66f87365d3e749dd
parentbe84f91f87a787ebfa8a346e936a5c88bc87b047
[LoopUnroll] Freeze tripcount rather than condition

This is a followup to D125754. We introduce two branches, one
before the unrolled loop and one before the epilogue (and similar
for the prologue case). The previous patch only froze the
condition on the first branch.

Rather than independently freezing the second condition, this patch
instead freezes TripCount and bases BECount on it. These are the
two quantities involved in the conditions, and this ensures that
both work on a consistent, non-poisonous trip count.

Differential Revision: https://reviews.llvm.org/D125896
llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
llvm/test/Transforms/LoopUnroll/runtime-loop-at-most-two-exits.ll
llvm/test/Transforms/LoopUnroll/runtime-loop-multiexit-dom-verify.ll
llvm/test/Transforms/LoopUnroll/runtime-loop-multiple-exits.ll
llvm/test/Transforms/LoopUnroll/runtime-multiexit-heuristic.ll