[llvm] 3fa5876 - [RISCV] Reorganize getShuffleCost to make it more clear what's going on [nfc]

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 6 10:12:43 PDT 2022


Author: Philip Reames
Date: 2022-06-06T10:11:58-07:00
New Revision: 3fa5876216bf35f65bef5d9563f73578b0269bc9

URL: https://github.com/llvm/llvm-project/commit/3fa5876216bf35f65bef5d9563f73578b0269bc9
DIFF: https://github.com/llvm/llvm-project/commit/3fa5876216bf35f65bef5d9563f73578b0269bc9.diff

LOG: [RISCV] Reorganize getShuffleCost to make it more clear what's going on [nfc]

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 1822640c74bae..a73bcf1c81bbd 100644
--- a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
@@ -177,12 +177,21 @@ InstructionCost RISCVTTIImpl::getShuffleCost(TTI::ShuffleKind Kind,
                                              VectorType *Tp, ArrayRef<int> Mask,
                                              int Index, VectorType *SubTp,
                                              ArrayRef<const Value *> Args) {
-  if (Kind == TTI::SK_Splice && isa<ScalableVectorType>(Tp))
-    return getSpliceCost(Tp, Index);
-
-  std::pair<InstructionCost, MVT> LT = TLI->getTypeLegalizationCost(DL, Tp);
-  if (Kind == TTI::SK_Broadcast && isa<ScalableVectorType>(Tp))
-    return LT.first * 1;
+  if (isa<ScalableVectorType>(Tp)) {
+    switch (Kind) {
+    default:
+      // Fallthrough to generic handling.
+      // TODO: Most of these cases will return getInvalid in generic code, and
+      // must be implemented here.
+      break;
+    case TTI::SK_Broadcast: {
+      std::pair<InstructionCost, MVT> LT = TLI->getTypeLegalizationCost(DL, Tp);
+      return LT.first * 1;
+    }
+    case TTI::SK_Splice:
+      return getSpliceCost(Tp, Index);
+    }
+  }
 
   return BaseT::getShuffleCost(Kind, Tp, Mask, Index, SubTp);
 }


        


More information about the llvm-commits mailing list