[llvm] [LV] Ignore some costs when loop gets fully unrolled (PR #106699)
Nick Desaulniers via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 9 10:29:58 PST 2024
================
@@ -2682,6 +2682,25 @@ static Value *getExpandedStep(const InductionDescriptor &ID,
return I->second;
}
+/// Knowing that loop \p L executes a single vector iteration, add instructions
+/// that will get simplified and thus should not have any cost to \p
+/// InstsToIgnore.
+static void addFullyUnrolledInstructionsToIgnore(
+ Loop *L, const LoopVectorizationLegality::InductionList &IL,
+ SmallPtrSetImpl<Instruction *> &InstsToIgnore) {
+ auto *Cmp = L->getLatchCmpInst();
+ if (Cmp)
+ InstsToIgnore.insert(Cmp);
+ for (const auto &[IV, IndDesc] : IL) {
+ // Get next iteration value of the induction variable.
+ Instruction *IVInst =
+ cast<Instruction>(IV->getIncomingValueForBlock(L->getLoopLatch()));
+ if (all_of(IVInst->users(),
+ [&](const User *U) { return U == IV || U == Cmp; }))
----------------
nickdesaulniers wrote:
https://lab.llvm.org/buildbot/#/builders/78/builds/11135:
```
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-runtimes-build/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:2699:49: error: reference to local binding 'IV' declared in enclosing function 'addFullyUnrolledInstructionsToIgnore'
[&](const User *U) { return U == IV || U == Cmp; }))
^
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-runtimes-build/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:2694:21: note: 'IV' declared here
for (const auto &[IV, IndDesc] : IL) {
^
```
https://github.com/llvm/llvm-project/pull/106699
More information about the llvm-commits
mailing list