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

Igor Kirillov via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 13 06:46:30 PST 2024


================
@@ -7221,6 +7235,20 @@ LoopVectorizationPlanner::precomputeCosts(VPlan &Plan, ElementCount VF,
         continue;
       IVInsts.push_back(CI);
     }
+
+    // If with the given VF loop gets fully unrolled, ignore the costs of
+    // comparison and induction instructions, as they'll get simplified away
+    auto TC = CM.PSE.getSE()->getSmallConstantTripCount(OrigLoop);
+    auto *Cmp = OrigLoop->getLatchCmpInst();
+    if (Cmp && TC == VF.getKnownMinValue()) {
----------------
igogo-x86 wrote:

Unfortunately remove comparison cost isn't enough, we need to remove next iteration induction cost too

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


More information about the llvm-commits mailing list