Skip to content

[mlir][LLVM] Use int32_t to indirectly construct GEPArg #79562

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,8 @@ LogicalResult GPUPrintfOpToVPrintfLowering::matchAndRewrite(
/*alignment=*/0);
for (auto [index, arg] : llvm::enumerate(args)) {
Value ptr = rewriter.create<LLVM::GEPOp>(
loc, ptrType, structType, tempAlloc, ArrayRef<LLVM::GEPArg>{0, index});
loc, ptrType, structType, tempAlloc,
ArrayRef<LLVM::GEPArg>{0, static_cast<int32_t>(index)});
rewriter.create<LLVM::StoreOp>(loc, arg, ptr);
}
std::array<Value, 2> printfArgs = {stringStart, tempAlloc};
Expand Down
9 changes: 5 additions & 4 deletions mlir/lib/Conversion/GPUCommon/GPUToLLVMConversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1041,13 +1041,14 @@ Value ConvertLaunchFuncOpToGpuRuntimeCallPattern::generateParamsArray(
auto arrayPtr = builder.create<LLVM::AllocaOp>(
loc, llvmPointerType, llvmPointerType, arraySize, /*alignment=*/0);
for (const auto &en : llvm::enumerate(arguments)) {
const auto index = static_cast<int32_t>(en.index());
Value fieldPtr =
builder.create<LLVM::GEPOp>(loc, llvmPointerType, structType, structPtr,
ArrayRef<LLVM::GEPArg>{0, en.index()});
ArrayRef<LLVM::GEPArg>{0, index});
builder.create<LLVM::StoreOp>(loc, en.value(), fieldPtr);
auto elementPtr = builder.create<LLVM::GEPOp>(
loc, llvmPointerType, llvmPointerType, arrayPtr,
ArrayRef<LLVM::GEPArg>{en.index()});
auto elementPtr =
builder.create<LLVM::GEPOp>(loc, llvmPointerType, llvmPointerType,
arrayPtr, ArrayRef<LLVM::GEPArg>{index});
builder.create<LLVM::StoreOp>(loc, fieldPtr, elementPtr);
}
return arrayPtr;
Expand Down
9 changes: 5 additions & 4 deletions mlir/lib/Dialect/LLVMIR/Transforms/TypeConsistency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,8 @@ static void splitVectorStore(const DataLayout &dataLayout, Location loc,
// Other patterns will turn this into a type-consistent GEP.
auto gepOp = rewriter.create<GEPOp>(
loc, address.getType(), rewriter.getI8Type(), address,
ArrayRef<GEPArg>{storeOffset + index * elementSize});
ArrayRef<GEPArg>{
static_cast<int32_t>(storeOffset + index * elementSize)});

rewriter.create<StoreOp>(loc, extractOp, gepOp);
}
Expand Down Expand Up @@ -524,9 +525,9 @@ static void splitIntegerStore(const DataLayout &dataLayout, Location loc,

// We create an `i8` indexed GEP here as that is the easiest (offset is
// already known). Other patterns turn this into a type-consistent GEP.
auto gepOp =
rewriter.create<GEPOp>(loc, address.getType(), rewriter.getI8Type(),
address, ArrayRef<GEPArg>{currentOffset});
auto gepOp = rewriter.create<GEPOp>(
loc, address.getType(), rewriter.getI8Type(), address,
ArrayRef<GEPArg>{static_cast<int32_t>(currentOffset)});
rewriter.create<StoreOp>(loc, valueToStore, gepOp);

// No need to care about padding here since we already checked previously
Expand Down