forked from OSchip/llvm-project
[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
This commit is contained in:
parent
c3c9312f70
commit
b841ae55e5
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue