[Loop Peeling] Do not close further unroll/peel if profile based peeling was not...
authorSerguei Katkov <serguei.katkov@azul.com>
Fri, 2 Aug 2019 04:29:23 +0000 (04:29 +0000)
committerSerguei Katkov <serguei.katkov@azul.com>
Fri, 2 Aug 2019 04:29:23 +0000 (04:29 +0000)
commitbbdcc8211111fa8e723a1754e0962e56141a2890
treef3496e17cdf7667382d11d263014a40e166093e3
parent6fe00a21f2436490f1c05247c612866dd59c03a5
[Loop Peeling] Do not close further unroll/peel if profile based peeling was not used.

Current peeling cost model can decide to peel off not all iterations
but only some of them to eliminate conditions on phi. At the same time
if any peeling happens the door for further unroll/peel optimizations on that
loop closes because the part of the code thinks that if peeling happened
it is profile based peeling and all iterations are peeled off.

To resolve this inconsistency the patch provides the flag which states whether
the full peeling basing on profile is enabled or not and peeling cost model
is able to modify this field like it does not PeelCount.

In a separate patch I will introduce an option to allow/disallow peeling basing
on profile.

To avoid infinite loop peeling the patch tracks the total number of peeled iteration
through llvm.loop.peeled.count loop metadata.

Reviewers: reames, fhahn
Reviewed By: reames
Subscribers: hiraditya, zzheng, dmgreen, llvm-commits
Differential Revision: https://reviews.llvm.org/D64972

llvm-svn: 367647
llvm/include/llvm/Analysis/TargetTransformInfo.h
llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
llvm/lib/Transforms/Utils/LoopUnrollPeel.cpp
llvm/test/Transforms/LoopUnroll/peel-loop-conditions-pgo-1.ll [new file with mode: 0644]
llvm/test/Transforms/LoopUnroll/peel-loop-conditions-pgo-2.ll [new file with mode: 0644]
llvm/test/Transforms/LoopUnroll/peel-loop-conditions.ll