[PATCH] D129994: [RISCV] Add cost modelling for vector widenning integer reduction.

Jianjian Guan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 3 04:26:18 PDT 2022


jacquesguan added a comment.

In D129994#3694016 <https://reviews.llvm.org/D129994#3694016>, @reames wrote:

> Thanks for the rework of the API, much improved!
>
> I'd still *prefer* a vectorizer test here, but won't strictly require one.

I add a test which will show the difference between the inloop reduction and outloop. In RISCV, we could use widening reduction instruction if we do the inloop reduction. But the API preferInLoopReduction maybe need some adjustment to enable the inloop reduction for the extended reduction situation, I will change it in a new revision.



================
Comment at: llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp:397
+
+  switch (ISD) {
+  case ISD::ADD:
----------------
reames wrote:
> It's not really clear to me why you bother to translate to ISD here.  The code would be much clearer as:
> 
> 
> ```
> if (Opcode != Add && Opcode != FAdd)
>   return ...
> if (width check fails)
>   return ...
> 
> std::pair<InstructionCost, MVT> LT = TLI->getTypeLegalizationCost(DL, ValTy);
> return (LT.first - 1) +
>              getArithmeticReductionCost(Opcode, ValTy, FMF, CostKind);
> ```
Done.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129994/new/

https://reviews.llvm.org/D129994



More information about the llvm-commits mailing list