[runtime] Move prolog/epilog block to a post-simplify strategy
authorPhilip Reames <listmail@philipreames.com>
Tue, 31 Aug 2021 16:29:36 +0000 (09:29 -0700)
committerPhilip Reames <listmail@philipreames.com>
Tue, 31 Aug 2021 16:29:36 +0000 (09:29 -0700)
commitb604fcb7bc9c4c3bf15479c8406eb69f582fb71b
tree99d5448ed9cec2590632e6534ec6e8508e10a33b
parent9b45fd909ffa754acbb4e927bc2d55c7ab0d4e3f
[runtime] Move prolog/epilog block to a post-simplify strategy

The runtime unroller will try to produce a non-loop if the unroll count is 2 and thus the prolog/epilog loop would only run at most one iteration. The old implementation did this by avoiding loop construction entirely. This patches instead constructs the trivial loop and then explicitly breaks the backedge and simplifies. This does result in some additional code churn when triggered, but a) results in better quality code and b) removes a codepath which didn't work properly for multiple exit epilogs.

One oddity that I want to draw to reviewer attention is that this somehow changes revisit order. The new order looks equivalent to me, but I don't understand how creating and erasing an extra loop here creates this effect.

Differential Revision: https://reviews.llvm.org/D108521
llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
llvm/test/Transforms/LoopUnroll/PowerPC/p8-unrolling-legalize-vectors-inseltpoison.ll
llvm/test/Transforms/LoopUnroll/PowerPC/p8-unrolling-legalize-vectors.ll
llvm/test/Transforms/LoopUnroll/revisit.ll
llvm/test/Transforms/LoopUnroll/runtime-loop-multiple-exits.ll
llvm/test/Transforms/LoopUnroll/runtime-loop1.ll
llvm/test/Transforms/LoopUnroll/runtime-unroll-assume-no-remainder.ll