[llvm] [AMDGPU] Enable vectorization of i8 values. (PR #134934)

Jeffrey Byrnes via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 23 16:52:17 PDT 2025


================
@@ -1423,3 +1424,32 @@ void GCNTTIImpl::collectKernelLaunchBounds(
   LB.push_back({"amdgpu-waves-per-eu[0]", WavesPerEU.first});
   LB.push_back({"amdgpu-waves-per-eu[1]", WavesPerEU.second});
 }
+
+InstructionCost GCNTTIImpl::getMemoryOpCost(unsigned Opcode, Type *Src,
+                                            Align Alignment,
+                                            unsigned AddressSpace,
+                                            TTI::TargetCostKind CostKind,
+                                            TTI::OperandValueInfo OpInfo,
+                                            const Instruction *I) {
+  if (VectorType *VecTy = dyn_cast<VectorType>(Src))
+    if (Opcode == Instruction::Load &&
+        VecTy->getElementType() ==
+            IntegerType::getInt8Ty(VecTy->getContext())) {
+      unsigned ElementCount = VecTy->getElementCount().getFixedValue();
+      return (8 * (ElementCount - 1) /
----------------
jrbyrnes wrote:

`return (8 * (ElementCount - 1) / getLoadStoreVecRegBitWidth(AddressSpace)) + 1;`
->
`return (DL.getTypeSizeInBits(VecTy) / getLoadStoreVecRegBitWidth(AddressSpace)) + 1;`

https://github.com/llvm/llvm-project/pull/134934


More information about the llvm-commits mailing list