[llvm] 2246700 - [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:13:16 PDT 2023


Author: Philip Reames
Date: 2023-08-23T14:13:07-07:00
New Revision: 2246700e7b25e60ea682525b6995e72d69968984

URL: https://github.com/llvm/llvm-project/commit/2246700e7b25e60ea682525b6995e72d69968984
DIFF: https://github.com/llvm/llvm-project/commit/2246700e7b25e60ea682525b6995e72d69968984.diff

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

Some callers pass in an empty mask to represent "unknown".  We should use the generic costs for these cases.  We can add VL=1 costing seperately if desired.

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 ecfcf64c7991d1..99a65265075a38 100644
--- a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
@@ -324,36 +324,33 @@ 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.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.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);
       }
       [[fallthrough]];
     }
     case TTI::SK_Transpose:
     case TTI::SK_PermuteTwoSrc: {
-      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;
-        }
+      // 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;
       }
       [[fallthrough]];
     }


        


More information about the llvm-commits mailing list