[Mlir-commits] [mlir] b841ae5 - [mlir] Fix SplatOp lowering to the LLVM dialect
Alex Zinenko
llvmlistbot at llvm.org
Tue Sep 7 10:14:37 PDT 2021
Author: Alex Zinenko
Date: 2021-09-07T19:14:28+02:00
New Revision: b841ae55e56392d5dfb4ce2ee7ef7cf56f2b81f9
URL: https://github.com/llvm/llvm-project/commit/b841ae55e56392d5dfb4ce2ee7ef7cf56f2b81f9
DIFF: https://github.com/llvm/llvm-project/commit/b841ae55e56392d5dfb4ce2ee7ef7cf56f2b81f9.diff
LOG: [mlir] Fix SplatOp lowering to the LLVM dialect
The lowering has been incorrectly using the operands of the original op instead
of rewritten operands provided to matchAndRewrite call. This may lead to
spurious materializations and generally invalid IR.
Reviewed By: aartbik
Differential Revision: https://reviews.llvm.org/D109355
Added:
Modified:
mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
index 5da2551cd43c1..3804c5e586563 100644
--- a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
+++ b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
@@ -875,6 +875,8 @@ struct SplatOpLowering : public ConvertOpToLLVMPattern<SplatOp> {
if (!resultType || resultType.getRank() != 1)
return failure();
+ SplatOp::Adaptor adaptor(operands);
+
// First insert it into an undef vector so we can shuffle it.
auto vectorType = typeConverter->convertType(splatOp.getType());
Value undef = rewriter.create<LLVM::UndefOp>(splatOp.getLoc(), vectorType);
@@ -884,7 +886,7 @@ struct SplatOpLowering : public ConvertOpToLLVMPattern<SplatOp> {
rewriter.getZeroAttr(rewriter.getIntegerType(32)));
auto v = rewriter.create<LLVM::InsertElementOp>(
- splatOp.getLoc(), vectorType, undef, splatOp.getOperand(), zero);
+ splatOp.getLoc(), vectorType, undef, adaptor.input(), zero);
int64_t width = splatOp.getType().cast<VectorType>().getDimSize(0);
SmallVector<int32_t, 4> zeroValues(width, 0);
More information about the Mlir-commits
mailing list