[llvm] f346cbd - [RISCV][TTI] Factor out getVRGatherVICost helper [nfc]

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 22 14:10:57 PDT 2023


Author: Philip Reames
Date: 2023-08-22T14:10:46-07:00
New Revision: f346cbd3788bb18385d64fd21db8548e62445dc1

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

LOG: [RISCV][TTI] Factor out getVRGatherVICost helper [nfc]

Reasonable implementations may differ in complexity cost, so doing some API prepwork to support tunables.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
index 7e77333b2c687e..720b2a0d7d8cc1 100644
--- a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
@@ -270,6 +270,13 @@ InstructionCost RISCVTTIImpl::getVRGatherVVCost(MVT VT) {
   return getLMULCost(VT) * getLMULCost(VT);
 }
 
+/// Return the cost of a vrgather.vi (or vx) instruction for the type VT.
+/// vrgather.vi/vx may be linear in the number of vregs implied by LMUL,
+/// or may track the vrgather.vv cost. It is implementation-dependent.
+InstructionCost RISCVTTIImpl::getVRGatherVICost(MVT VT) {
+  return getLMULCost(VT);
+}
+
 InstructionCost RISCVTTIImpl::getShuffleCost(TTI::ShuffleKind Kind,
                                              VectorType *Tp, ArrayRef<int> Mask,
                                              TTI::TargetCostKind CostKind,
@@ -436,9 +443,7 @@ InstructionCost RISCVTTIImpl::getShuffleCost(TTI::ShuffleKind Kind,
 
     // Example sequence:
     //   vrgather.vi     v9, v8, 0
-    // TODO: vrgather could be slower than vmv.v.x. It is
-    // implementation-dependent.
-    return LT.first * getLMULCost(LT.second);
+    return LT.first * getVRGatherVICost(LT.second);
   }
   case TTI::SK_Splice:
     // vslidedown+vslideup.

diff  --git a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h
index bbbc9f4881d101..9873046034e190 100644
--- a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h
+++ b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h
@@ -124,6 +124,7 @@ class RISCVTTIImpl : public BasicTTIImplBase<RISCVTTIImpl> {
   }
 
   InstructionCost getVRGatherVVCost(MVT VT);
+  InstructionCost getVRGatherVICost(MVT VT);
 
   InstructionCost getShuffleCost(TTI::ShuffleKind Kind, VectorType *Tp,
                                  ArrayRef<int> Mask,


        


More information about the llvm-commits mailing list