[llvm] 207cdd7 - [SLP] Fix spill cost computation for insertelement tree node

Anton Afanasyev via llvm-commits llvm-commits at lists.llvm.org
Fri May 14 03:15:47 PDT 2021


Author: Anton Afanasyev
Date: 2021-05-14T13:14:41+03:00
New Revision: 207cdd7ed9fc545a615d9bb244a7d9a2158e61ed

URL: https://github.com/llvm/llvm-project/commit/207cdd7ed9fc545a615d9bb244a7d9a2158e61ed
DIFF: https://github.com/llvm/llvm-project/commit/207cdd7ed9fc545a615d9bb244a7d9a2158e61ed.diff

LOG: [SLP] Fix spill cost computation for insertelement tree node

This is follow up for D98714, bugfixing.

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 99d9b05d28a3..89821d79458a 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -4317,8 +4317,12 @@ InstructionCost BoUpSLP::getSpillCost() const {
 
     if (NumCalls) {
       SmallVector<Type*, 4> V;
-      for (auto *II : LiveValues)
-        V.push_back(FixedVectorType::get(II->getType(), BundleWidth));
+      for (auto *II : LiveValues) {
+        auto *ScalarTy = II->getType();
+        if (auto *VectorTy = dyn_cast<FixedVectorType>(ScalarTy))
+          ScalarTy = VectorTy->getElementType();
+        V.push_back(FixedVectorType::get(ScalarTy, BundleWidth));
+      }
       Cost += NumCalls * TTI->getCostOfKeepingLiveOverCall(V);
     }
 


        


More information about the llvm-commits mailing list