[llvm] [SLP]Improve costs in computeExtractCost() to avoid crash after D158449. (PR #67142)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 27 03:04:45 PDT 2023


================
@@ -7067,30 +7067,56 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
   /// extracted values from \p VL.
   InstructionCost computeExtractCost(ArrayRef<Value *> VL, ArrayRef<int> Mask,
                                      TTI::ShuffleKind ShuffleKind) {
-    auto *VecTy = FixedVectorType::get(VL.front()->getType(), VL.size());
+    unsigned NumElts = 0;
+    for (Value *V : VL) {
+      auto *EE = dyn_cast<ExtractElementInst>(V);
+      if (!EE)
+        continue;
+      auto *VecTy = cast<FixedVectorType>(EE->getVectorOperandType());
+      NumElts = std::max(NumElts, VecTy->getNumElements());
+    }
----------------
RKSimon wrote:

assert / bail if NumElts == 0 after the loop?

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


More information about the llvm-commits mailing list