[llvm] fc89745 - [RISCV][NFC] Clarify getRISCVInstructionCost usage (#121556)

via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 2 23:49:11 PST 2025


Author: Shih-Po Hung
Date: 2025-02-03T15:49:07+08:00
New Revision: fc897450019bc0585f3592ee3a3d68bad2fdcbbc

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

LOG: [RISCV][NFC] Clarify getRISCVInstructionCost usage (#121556)

This patch adds a comment to explicitly state that
getRISCVInstructionCost uses vtype associated with widening and
narrowing instructions.
For example, vtype = (SEW):
For vfwcvt.f.f.v, the source is (SEW), the destination is (2 * SEW)
For vfncvt.f.f.w, the source is (2 * SEW), the destination is (SEW).
In these cases, the type passed to `getRISCVInstructionCost` differs
- The source type is used for `vfwcvt.f.f.v`.
- The destination type is used for `vfncvt.f.f.w`.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h
index 9b364391f0fa47..042530b9cd2b32 100644
--- a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h
+++ b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h
@@ -48,6 +48,14 @@ class RISCVTTIImpl : public BasicTTIImplBase<RISCVTTIImpl> {
   /// actual target hardware.
   unsigned getEstimatedVLFor(VectorType *Ty);
 
+  /// This function calculates the costs for one or more RVV opcodes based
+  /// on the vtype and the cost kind.
+  /// \param Opcodes A list of opcodes of the RVV instruction to evaluate.
+  /// \param VT The MVT of vtype associated with the RVV instructions.
+  /// For widening/narrowing instructions where the result and source types
+  /// 
diff er, it is important to check the spec to determine whether the vtype
+  /// refers to the result or source type.
+  /// \param CostKind The type of cost to compute.
   InstructionCost getRISCVInstructionCost(ArrayRef<unsigned> OpCodes, MVT VT,
                                           TTI::TargetCostKind CostKind);
 


        


More information about the llvm-commits mailing list