[PATCH] D135991: [AArch64] Fix cost model for `udiv` instruction when one of the operands is a uniform constant

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 25 00:30:06 PST 2022


dmgreen accepted this revision.
dmgreen added a comment.
This revision is now accepted and ready to land.

Other than changing the parameter passed through, this LGTM



================
Comment at: llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp:2090
 InstructionCost AArch64TTIImpl::getArithmeticInstrCost(
     unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,
     TTI::OperandValueInfo Op1Info, TTI::OperandValueInfo Op2Info,
----------------
This one :)


================
Comment at: llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp:2117
+            InstructionCost DivCost = BaseT::getArithmeticInstrCost(
+                Instruction::UDiv, Ty->getScalarType(), CostKind, Op1Info,
+                Op2Info);
----------------
zjaffal wrote:
> dmgreen wrote:
> > zjaffal wrote:
> > > dmgreen wrote:
> > > > Should UDiv be Opcode, to handle SDiv a little better?
> > > Do you mean using `ISD::UDiv` instead of `Instruction::UDiv`. 
> > > I tried that but it get the following error if I do that 
> > > ```
> > > Assertion failed: (ISD && "Invalid opcode"), function getArithmeticInstrCost, file BasicTTIImpl.h, line 834.
> > > ```
> > > We can do the following instead 
> > > ```
> > > int Opcdoe = (ISD == ISD::UDIV) ? Instruction::UDiv : Instruction::SDiv;
> > > ```
> > I just meant the variable/argument `Opcode` - as far as I understand it could be UDiv or SDiv here.
> We can do the following then
> ```
> int Opcdoe = (ISD == ISD::UDIV) ? Instruction::UDiv : Instruction::SDiv;
> ```
I think the Opcode parameter will already be the UDiv/SDiv, and can be used directly. Correct me if I'm wrong.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135991



More information about the llvm-commits mailing list