Perform memory accesses in the same addrspace as the corresponding memref.

It's not necessarily the case on all architectures that all memory is
addressable in addrspace 0, so casting the pointer to addrspace 0 is
liable to cause problems.

Reviewed By: aartbik, ftynse, nicolasvasilache

Differential Revision: https://reviews.llvm.org/D96380
This commit is contained in:
Andrew Pritchard
2021-02-18 12:21:11 -08:00
committed by Aart Bik
parent 97ec8fa5bb
commit 08c681f645
2 changed files with 9 additions and 12 deletions

View File

@@ -209,15 +209,12 @@ static LogicalResult getIndexedPtrs(ConversionPatternRewriter &rewriter,
return success();
}
// Casts a strided element pointer to a vector pointer. The vector pointer
// would always be on address space 0, therefore addrspacecast shall be
// used when source/dst memrefs are not on address space 0.
// Casts a strided element pointer to a vector pointer. The vector pointer
// will be in the same address space as the incoming memref type.
static Value castDataPtr(ConversionPatternRewriter &rewriter, Location loc,
Value ptr, MemRefType memRefType, Type vt) {
auto pType = LLVM::LLVMPointerType::get(vt);
if (memRefType.getMemorySpace() == 0)
return rewriter.create<LLVM::BitcastOp>(loc, pType, ptr);
return rewriter.create<LLVM::AddrSpaceCastOp>(loc, pType, ptr);
auto pType = LLVM::LLVMPointerType::get(vt, memRefType.getMemorySpace());
return rewriter.create<LLVM::BitcastOp>(loc, pType, ptr);
}
static LogicalResult