[llvm] [SLP][REVEC] Make ShuffleCostEstimator and ShuffleInstructionBuilder can vectorize vector instructions. (PR #99499)

Han-Kuan Chen via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 18 17:56:22 PDT 2024


================
@@ -9125,18 +9125,27 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
       if (MaskVF != 0)
         VF = std::min(VF, MaskVF);
       for (Value *V : VL.take_front(VF)) {
-        if (isa<UndefValue>(V)) {
-          Vals.push_back(cast<Constant>(V));
-          continue;
+        Type *Ty = V->getType();
+        Type *ScalarTy = Ty->getScalarType();
+        unsigned VNumElements = getNumElements(Ty);
+        for (unsigned I = 0; I != VNumElements; ++I) {
+          if (isa<PoisonValue>(V)) {
+            Vals.push_back(PoisonValue::get(ScalarTy));
+            continue;
+          }
+          if (isa<UndefValue>(V)) {
+            Vals.push_back(UndefValue::get(ScalarTy));
+            continue;
+          }
+          Vals.push_back(Constant::getNullValue(ScalarTy));
----------------
HanKuanChen wrote:

Fix. Add the expand logic in another loop.

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


More information about the llvm-commits mailing list