[PATCH] D25963: [LoopUnroll] Implement profile-based loop peeling
Michael Kuperstein via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 28 13:33:19 PDT 2016
mkuper marked an inline comment as done.
mkuper added inline comments.
================
Comment at: lib/Transforms/Utils/LoopUnroll.cpp:357
+ << " peeling loop %" << Header->getName() << " by "
+ << NV("PeelCount", PeelCount) << ".\n");
} else {
----------------
davidxl wrote:
> .\n --> iterations.\n
Sure.
================
Comment at: lib/Transforms/Utils/LoopUnrollPeel.cpp:63
+unsigned llvm::getPeelCount(Loop *L, unsigned LoopSize,
+ TargetTransformInfo::UnrollingPreferences *UP) {
+ if (!canPeel(L))
----------------
davidxl wrote:
> Is UP parameter intended to be used?
Sorry, I don't quite understand what you mean here. It is used (in line 84 or below). Could you explain?
================
Comment at: lib/Transforms/Utils/LoopUnrollPeel.cpp:121
+ BasicBlock *PreHeader, BasicBlock *Exit,
+ uint64_t &TotalLoopWeight,
+ SmallVectorImpl<BasicBlock *> &NewBlocks,
----------------
davidxl wrote:
> I think the following weights should be passed in:
>
>
> * TotalHeaderWeight of the currently peeled loop -- it is passed in for update:
> TotalHeaderWeight -= PeeledIterationHeaderWeight;
>
> * PeeledIterationHeaderWeight
> 1) its initial value for the first peeled iteration is the PreheaderWeight or ExitWeight of the original loop
> 2) After peeling of one iteration, its value will be updated to the fallthrough weight of the peel
>
> * TotalExitEdgeWeight -- passed in for update.
> After peeling, TotalExitEdgeWeight -= PeeledIterationExitWeight'
>
>
I don't think we need TotalExitEdgeWeight, but you're right, we need to accumulate the header weight to be able to update the final weight of the backedge properly.
================
Comment at: lib/Transforms/Utils/LoopUnrollPeel.cpp:168
+ uint64_t FallThruWeight =
+ TotalLoopWeight * ((float)(PeelCount - IterNumber) / PeelCount * 0.9);
+ uint64_t ExitWeight = TotalLoopWeight - FallThruWeight;
----------------
davidxl wrote:
> Should average trip count be used instead of PeelCount (which may be different)?
Right, I assumed they're the same (and currently they are), but it's not necessarily true in general, I'll add a parameter (and pass PeelCount).
https://reviews.llvm.org/D25963
More information about the llvm-commits
mailing list