[llvm] [RISCV][CostModel] Estimate cost of Extract/InsertElement with non-constant index when vector instructions are not available (PR #67334)

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 26 09:22:21 PDT 2023


================
@@ -1460,8 +1460,29 @@ InstructionCost RISCVTTIImpl::getVectorInstrCost(unsigned Opcode, Type *Val,
   std::pair<InstructionCost, MVT> LT = getTypeLegalizationCost(Val);
 
   // This type is legalized to a scalar type.
-  if (!LT.second.isVector())
-    return 0;
+  if (!LT.second.isVector()) {
+    auto *FixedVecTy = dyn_cast<FixedVectorType>(Val);
+    // Scalable vectors can't be legalized with scalars, return invalid cost.
+    if (!FixedVecTy)
----------------
preames wrote:

Does this bit actually get hit?  I'd have expected it to go through the  if (LT.second.isScalableVector() && !LT.first.isValid()) check just below.  

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


More information about the llvm-commits mailing list