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

Zain Jaffal via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 9 06:49:56 PST 2022


zjaffal added inline comments.


================
Comment at: llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp:18
 #include "llvm/CodeGen/CostTable.h"
+#include "llvm/CodeGen/ISDOpcodes.h"
 #include "llvm/CodeGen/TargetLowering.h"
----------------
dmgreen wrote:
> Are these changes necessary?
I don't think so. Automatic imports from vscode


================
Comment at: llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp:2117
+            InstructionCost DivCost = BaseT::getArithmeticInstrCost(
+                Instruction::UDiv, Ty->getScalarType(), CostKind, Op1Info,
+                Op2Info);
----------------
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;
```


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