[llvm] 4371ce9 - [NFC][SLPVectorizer] Capture TTI explicitly in the cost-caching lambdas (#223020)

via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 11 12:51:20 PDT 2026


Author: Kevin McAfee
Date: 2026-09-11T19:51:15Z
New Revision: 4371ce908668ab70cbf9cc938657a2230cb9f417

URL: https://github.com/llvm/llvm-project/commit/4371ce908668ab70cbf9cc938657a2230cb9f417
DIFF: https://github.com/llvm/llvm-project/commit/4371ce908668ab70cbf9cc938657a2230cb9f417.diff

LOG: [NFC][SLPVectorizer] Capture TTI explicitly in the cost-caching lambdas (#223020)

Follow-up to #122348, which converted a number of lambdas in this file
to capture the TTI member explicitly. Covers a couple sites that have
been added since.

Added: 
    

Modified: 
    llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index faf3518adfb83..a0adca7aabad0 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -6129,7 +6129,7 @@ BoUpSLP::LoadsState BoUpSLP::canVectorizeLoads(
   // post-branch check use the same VecTy/CommonAlignment, and the underlying
   // TTI calls are virtual.
   std::optional<bool> MaskedGatherLegal;
-  auto IsMaskedGatherLegal = [&] {
+  auto IsMaskedGatherLegal = [&, TTI = TTI] {
     if (!MaskedGatherLegal)
       MaskedGatherLegal =
           TTI->isLegalMaskedGather(VecTy, CommonAlignment) &&
@@ -13963,7 +13963,7 @@ void BoUpSLP::transformNodes() {
             if (VF == 2) {
               // Cache the cost check lazily - both branches below may need it.
               std::optional<bool> MainOpIsCheap;
-              auto IsMainOpCheap = [&] {
+              auto IsMainOpCheap = [&, TTI = TTI] {
                 if (!MainOpIsCheap)
                   MainOpIsCheap =
                       TTI->getInstructionCost(S.getMainOp(), CostKind) <


        


More information about the llvm-commits mailing list