[Mlir-commits] [mlir] a99f62c - [mlir] VectorToLLVM: propagate up from replaceTransferOp
Alex Zinenko
llvmlistbot at llvm.org
Thu May 7 02:53:58 PDT 2020
Author: Alex Zinenko
Date: 2020-05-07T11:53:48+02:00
New Revision: a99f62c40a2ec5d54d841dc35006683cb70861a4
URL: https://github.com/llvm/llvm-project/commit/a99f62c40a2ec5d54d841dc35006683cb70861a4
DIFF: https://github.com/llvm/llvm-project/commit/a99f62c40a2ec5d54d841dc35006683cb70861a4.diff
LOG: [mlir] VectorToLLVM: propagate up from replaceTransferOp
In the Vector to LLVM conversion, the `replaceTransferOp` function calls
into a type converter that may fail and suppresses the status. Change
the function to return the failure status instead, Since it is called
from a pattern, the failure can be readily propagated to the rest of
infrastructure.
Added:
Modified:
mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
index 423b93b42e00..1dea41b2d99d 100644
--- a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
+++ b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
@@ -747,10 +747,10 @@ class VectorTypeCastOpConversion : public ConvertToLLVMPattern {
};
template <typename ConcreteOp>
-void replaceTransferOp(ConversionPatternRewriter &rewriter,
- LLVMTypeConverter &typeConverter, Location loc,
- Operation *op, ArrayRef<Value> operands, Value dataPtr,
- Value mask);
+LogicalResult replaceTransferOp(ConversionPatternRewriter &rewriter,
+ LLVMTypeConverter &typeConverter, Location loc,
+ Operation *op, ArrayRef<Value> operands,
+ Value dataPtr, Value mask);
LogicalResult getLLVMTypeAndAlignment(LLVMTypeConverter &typeConverter,
Type type, LLVM::LLVMType &llvmType,
@@ -766,11 +766,10 @@ LogicalResult getLLVMTypeAndAlignment(LLVMTypeConverter &typeConverter,
}
template <>
-void replaceTransferOp<TransferReadOp>(ConversionPatternRewriter &rewriter,
- LLVMTypeConverter &typeConverter,
- Location loc, Operation *op,
- ArrayRef<Value> operands, Value dataPtr,
- Value mask) {
+LogicalResult replaceTransferOp<TransferReadOp>(
+ ConversionPatternRewriter &rewriter, LLVMTypeConverter &typeConverter,
+ Location loc, Operation *op, ArrayRef<Value> operands, Value dataPtr,
+ Value mask) {
auto xferOp = cast<TransferReadOp>(op);
auto toLLVMTy = [&](Type t) { return typeConverter.convertType(t); };
VectorType fillType = xferOp.getVectorType();
@@ -779,28 +778,33 @@ void replaceTransferOp<TransferReadOp>(ConversionPatternRewriter &rewriter,
LLVM::LLVMType vecTy;
unsigned align;
- if (succeeded(getLLVMTypeAndAlignment(typeConverter, xferOp.getVectorType(),
- vecTy, align)))
- rewriter.replaceOpWithNewOp<LLVM::MaskedLoadOp>(
- op, vecTy, dataPtr, mask, ValueRange{fill},
- rewriter.getI32IntegerAttr(align));
+ if (failed(getLLVMTypeAndAlignment(typeConverter, xferOp.getVectorType(),
+ vecTy, align)))
+ return failure();
+
+ rewriter.replaceOpWithNewOp<LLVM::MaskedLoadOp>(
+ op, vecTy, dataPtr, mask, ValueRange{fill},
+ rewriter.getI32IntegerAttr(align));
+ return success();
}
template <>
-void replaceTransferOp<TransferWriteOp>(ConversionPatternRewriter &rewriter,
- LLVMTypeConverter &typeConverter,
- Location loc, Operation *op,
- ArrayRef<Value> operands, Value dataPtr,
- Value mask) {
+LogicalResult replaceTransferOp<TransferWriteOp>(
+ ConversionPatternRewriter &rewriter, LLVMTypeConverter &typeConverter,
+ Location loc, Operation *op, ArrayRef<Value> operands, Value dataPtr,
+ Value mask) {
auto adaptor = TransferWriteOpOperandAdaptor(operands);
auto xferOp = cast<TransferWriteOp>(op);
LLVM::LLVMType vecTy;
unsigned align;
- if (succeeded(getLLVMTypeAndAlignment(typeConverter, xferOp.getVectorType(),
- vecTy, align)))
- rewriter.replaceOpWithNewOp<LLVM::MaskedStoreOp>(
- op, adaptor.vector(), dataPtr, mask, rewriter.getI32IntegerAttr(align));
+ if (failed(getLLVMTypeAndAlignment(typeConverter, xferOp.getVectorType(),
+ vecTy, align)))
+ return failure();
+
+ rewriter.replaceOpWithNewOp<LLVM::MaskedStoreOp>(
+ op, adaptor.vector(), dataPtr, mask, rewriter.getI32IntegerAttr(align));
+ return success();
}
static TransferReadOpOperandAdaptor
@@ -906,10 +910,8 @@ class VectorTransferConversion : public ConvertToLLVMPattern {
mask);
// 5. Rewrite as a masked read / write.
- replaceTransferOp<ConcreteOp>(rewriter, typeConverter, loc, op, operands,
- vectorDataPtr, mask);
-
- return success();
+ return replaceTransferOp<ConcreteOp>(rewriter, typeConverter, loc, op,
+ operands, vectorDataPtr, mask);
}
};
More information about the Mlir-commits
mailing list