[PATCH] D116336: [RISCV] Initial support for scalable vectorization

Alex via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 28 11:00:53 PST 2021


alextsao1999 created this revision.
Herald added subscribers: VincentWu, luke957, achieveartificialintelligence, vkmr, frasercrmck, evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, hiraditya.
alextsao1999 requested review of this revision.
Herald added subscribers: llvm-commits, MaskRay.
Herald added a project: LLVM.

Initial support for scalable vectorization.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116336

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


Index: llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h
===================================================================
--- llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h
+++ llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h
@@ -56,7 +56,6 @@
 
   bool shouldExpandReduction(const IntrinsicInst *II) const;
   bool supportsScalableVectors() const { return ST->hasVInstructions(); }
-  bool enableScalableVectorization() const { return ST->hasVInstructions(); }
   Optional<unsigned> getMaxVScale() const;
 
   TypeSize getRegisterBitWidth(TargetTransformInfo::RegisterKind K) const {
Index: llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
===================================================================
--- llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
+++ llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
@@ -164,10 +164,10 @@
 }
 
 InstructionCost RISCVTTIImpl::getCastInstrCost(unsigned Opcode, Type *Dst,
-                                                 Type *Src,
-                                                 TTI::CastContextHint CCH,
-                                                 TTI::TargetCostKind CostKind,
-                                                 const Instruction *I) {
+                                               Type *Src,
+                                               TTI::CastContextHint CCH,
+                                               TTI::TargetCostKind CostKind,
+                                               const Instruction *I) {
   int ISD = TLI->InstructionOpcodeToISD(Opcode);
   assert(ISD && "Invalid opcode");
 
@@ -187,7 +187,8 @@
 
   if (ISD == ISD::ZERO_EXTEND && SrcTy.isScalableVector() &&
       DstTy.isScalableVector()) {
-    if (SrcTy.isInteger() && DstTy.isInteger()) {
+    if (SrcTy.isInteger() && DstTy.isInteger() &&
+        SrcTy.getVectorElementCount() == DstTy.getVectorElementCount()) {
       if (SrcTy.getScalarSizeInBits() <= DstTy.getScalarSizeInBits()) {
         return 0;
       }
@@ -196,7 +197,6 @@
 
   return AdjustCost(
       BaseT::getCastInstrCost(Opcode, Dst, Src, CCH, CostKind, I));
-
 }
 
 void RISCVTTIImpl::getUnrollingPreferences(Loop *L, ScalarEvolution &SE,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116336.396411.patch
Type: text/x-patch
Size: 2181 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211228/ce627697/attachment.bin>


More information about the llvm-commits mailing list