[PATCH] D131114: [AArch64][TTI][NFC] Overload method 'getVectorInstrCost' to provide vector instruction itself, as a context information for cost estimation.
Mingming Liu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 4 11:03:17 PDT 2022
mingmingl added inline comments.
================
Comment at: llvm/include/llvm/Analysis/TargetTransformInfo.h:1181
+ /// exists (e.g., from basic blocks during transformation).
+ InstructionCost getVectorInstrCost(const Instruction *I, Type *Val,
+ unsigned Index = -1) const;
----------------
davidxl wrote:
> Is the Type *val always from instruction? If yes, this parameter can be removed. Alternatively add an assert in the implementation that I->getType() == Val. The latter may be better as Type is readily available at callsite.
`Type* val` (representing vector type) could be retrieved from `Instruction* I` but not necessarily `I->getType()` (scalar for extract-element, and vector for insert-element)
For example, AArch64 TTI requires that `Type* val` is always vector type ([[ https://github.com/llvm/llvm-project/blob/010f329803c84e43ec15ffaff7b6e26b032cbcc6/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp#L1953 | code of asserts ]]), while `I->getType()` for extract-element is the element type ([[ https://github.com/llvm/llvm-project/blob/010f329803c84e43ec15ffaff7b6e26b032cbcc6/llvm/lib/IR/Instructions.cpp#L1861 | code of EEI constructor ]])
For insert-element it should be true, since it's intentional that "there is only one instance of a particular type so that type comparison becomes pointer comparison" ([[ https://github.com/llvm/llvm-project/blob/4038c859e58c12e997041927a87e880f2f3ef883/llvm/include/llvm/IR/Type.h#L40 | class description of type ]])
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D131114/new/
https://reviews.llvm.org/D131114
More information about the llvm-commits
mailing list