[llvm] 84e5278 - Revert "[RISCV] Remove mask size restriction on single source and dual src shuffle costing"

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 23 14:25:15 PDT 2023


Author: Philip Reames
Date: 2023-08-23T14:25:03-07:00
New Revision: 84e5278229f493a22bf15ca6e266b2a72ffe780c

URL: https://github.com/llvm/llvm-project/commit/84e5278229f493a22bf15ca6e266b2a72ffe780c
DIFF: https://github.com/llvm/llvm-project/commit/84e5278229f493a22bf15ca6e266b2a72ffe780c.diff

LOG: Revert "[RISCV] Remove mask size restriction on single source and dual src shuffle costing"

This reverts commit 2246700e7b25e60ea682525b6995e72d69968984.  Seeing buildbot failures; it looks like I rebased over a new test which is effected by the change.

Added: 
    

Modified: 
    llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
index 99a65265075a38..ecfcf64c7991d1 100644
--- a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
@@ -324,33 +324,36 @@ InstructionCost RISCVTTIImpl::getShuffleCost(TTI::ShuffleKind Kind,
               return LT.first * getLMULCost(LT.second);
           }
         }
-      }
-      // vrgather + cost of generating the mask constant.
-      // We model this for an unknown mask with a single vrgather.
-      if (LT.second.isFixedLengthVector() && LT.first == 1 &&
-          (LT.second.getScalarSizeInBits() != 8 ||
-           LT.second.getVectorNumElements() <= 256)) {
-        VectorType *IdxTy = getVRGatherIndexType(LT.second, *ST, Tp->getContext());
-        InstructionCost IndexCost = getConstantPoolLoadCost(IdxTy, CostKind);
-        return IndexCost + getVRGatherVVCost(LT.second);
+
+        // vrgather + cost of generating the mask constant.
+        // We model this for an unknown mask with a single vrgather.
+        if (LT.first == 1 &&
+            (LT.second.getScalarSizeInBits() != 8 ||
+             LT.second.getVectorNumElements() <= 256)) {
+          VectorType *IdxTy = getVRGatherIndexType(LT.second, *ST, Tp->getContext());
+          InstructionCost IndexCost = getConstantPoolLoadCost(IdxTy, CostKind);
+          return IndexCost + getVRGatherVVCost(LT.second);
+        }
       }
       [[fallthrough]];
     }
     case TTI::SK_Transpose:
     case TTI::SK_PermuteTwoSrc: {
-      // 2 x (vrgather + cost of generating the mask constant) + cost of mask
-      // register for the second vrgather. We model this for an unknown
-      // (shuffle) mask.
-      if (LT.second.isFixedLengthVector() && LT.first == 1 &&
-          (LT.second.getScalarSizeInBits() != 8 ||
-           LT.second.getVectorNumElements() <= 256)) {
-        auto &C = Tp->getContext();
-        auto EC = Tp->getElementCount();
-        VectorType *IdxTy = getVRGatherIndexType(LT.second, *ST, C);
-        VectorType *MaskTy = VectorType::get(IntegerType::getInt1Ty(C), EC);
-        InstructionCost IndexCost = getConstantPoolLoadCost(IdxTy, CostKind);
-        InstructionCost MaskCost = getConstantPoolLoadCost(MaskTy, CostKind);
-        return 2 * IndexCost + 2 * getVRGatherVVCost(LT.second) + MaskCost;
+      if (Mask.size() >= 2 && LT.second.isFixedLengthVector()) {
+        // 2 x (vrgather + cost of generating the mask constant) + cost of mask
+        // register for the second vrgather. We model this for an unknown
+        // (shuffle) mask.
+        if (LT.first == 1 &&
+            (LT.second.getScalarSizeInBits() != 8 ||
+             LT.second.getVectorNumElements() <= 256)) {
+          auto &C = Tp->getContext();
+          auto EC = Tp->getElementCount();
+          VectorType *IdxTy = getVRGatherIndexType(LT.second, *ST, C);
+          VectorType *MaskTy = VectorType::get(IntegerType::getInt1Ty(C), EC);
+          InstructionCost IndexCost = getConstantPoolLoadCost(IdxTy, CostKind);
+          InstructionCost MaskCost = getConstantPoolLoadCost(MaskTy, CostKind);
+          return 2 * IndexCost + 2 * getVRGatherVVCost(LT.second) + MaskCost;
+        }
       }
       [[fallthrough]];
     }


        


More information about the llvm-commits mailing list