[Mlir-commits] [mlir] [mlir][amdgpu] Lower make_gather_dma_descriptor. (PR #172083)

Erick Ochoa Lopez llvmlistbot at llvm.org
Mon Dec 15 08:42:55 PST 2025


================
@@ -2896,8 +2931,81 @@ struct AMDGPUMakeDmaDescriptorLowering
     return dgroup2;
   }
 
+  Value getGatherIndices(DescriptorOp op, OpAdaptor adaptor,
+                         ConversionPatternRewriter &rewriter, Location loc,
+                         ArrayRef<Value> consts, bool firstHalf) const {
+    IntegerType i32 = rewriter.getI32Type();
+    Type v4i32 = this->typeConverter->convertType(VectorType::get(4, i32));
+    assert(v4i32 && "expected type conversion to succeed.");
+
+    if (!op.getIndices())
+      return LLVM::PoisonOp::create(rewriter, loc, v4i32);
+
+    Value indices = adaptor.getIndices();
+    auto vectorType = cast<VectorType>(indices.getType());
+    unsigned length = vectorType.getShape().back();
+    Type elementType = vectorType.getElementType();
+    unsigned maxLength = elementType == i32 ? 4 : 8;
+    int32_t offset = firstHalf ? 0 : maxLength;
+    unsigned discountedLength =
+        std::max(static_cast<int32_t>(length - offset), 0);
+
+    unsigned targetSize = std::min(maxLength, discountedLength);
+
+    SmallVector<Value> indicesVector;
+    for (unsigned i = offset; i < targetSize + offset; i++) {
----------------
amd-eochoalo wrote:

https://github.com/llvm/llvm-project/pull/172083/commits/141822a4abfbac07fa62361c019857f8eebec0cc Thanks! I also removed the optional indices as chatted on slack. Let me know what you think. I'll wait until end of day to merge. Thanks!

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


More information about the Mlir-commits mailing list