[llvm] [AMDGPU] Cost of i8 vector insert/extract is free in some cases (PR #194991)
Janek van Oirschot via llvm-commits
llvm-commits at lists.llvm.org
Tue May 5 07:32:30 PDT 2026
================
@@ -1009,19 +1009,32 @@ InstructionCost GCNTTIImpl::getVectorInstrCost(
case Instruction::InsertElement: {
unsigned EltSize
= DL.getTypeSizeInBits(cast<VectorType>(ValTy)->getElementType());
+ // Dynamic indexing isn't free and is best avoided.
+ if (Index == ~0u)
+ return 2;
----------------
JanekvO wrote:
I assume this needs to be checked here now because `index` is used with the computation for `EltSize == 8`? Are there any unintentional side-effects that you are aware of, of cases that would previously fall into `return BaseT::getVectorInstrCost` (e.g., cases like `EltSize == 16 && Index != 0` or `EltSize < 32 && !ST->has16BitInsts()`)? (For all I know, `BaseT::getVectorInstrCost` does the exact same of returning 2 for dynamic indices, but I'm not sure)
https://github.com/llvm/llvm-project/pull/194991
More information about the llvm-commits
mailing list