[llvm] [LV] Ignore some costs when loop gets fully unrolled (PR #106699)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 6 03:46:15 PST 2024


================
@@ -2652,6 +2652,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)
----------------
david-arm wrote:

Hmm, I just thought of something. What if there is an additional use of `Cmp` outside the loop? Should we also be checking that there is only a single use?

https://github.com/llvm/llvm-project/pull/106699


More information about the llvm-commits mailing list