[Mlir-commits] [mlir] 0c2a4d3 - [mlir][VectorOps] Simplify code. NFCI.
Benjamin Kramer
llvmlistbot at llvm.org
Fri Sep 4 02:12:52 PDT 2020
Author: Benjamin Kramer
Date: 2020-09-04T11:10:20+02:00
New Revision: 0c2a4d3c1c95c8217e9e00d5a20feed0d5c37ac5
URL: https://github.com/llvm/llvm-project/commit/0c2a4d3c1c95c8217e9e00d5a20feed0d5c37ac5
DIFF: https://github.com/llvm/llvm-project/commit/0c2a4d3c1c95c8217e9e00d5a20feed0d5c37ac5.diff
LOG: [mlir][VectorOps] Simplify code. NFCI.
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 dfa204d17389..a43bec855ff0 100644
--- a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
+++ b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
@@ -134,18 +134,14 @@ static Value buildVectorComparison(ConversionPatternRewriter &rewriter,
Value indices;
Type idxType;
if (enableIndexOptimizations) {
- SmallVector<int32_t, 4> values(dim);
- for (int64_t d = 0; d < dim; d++)
- values[d] = d;
- indices =
- rewriter.create<ConstantOp>(loc, rewriter.getI32VectorAttr(values));
+ indices = rewriter.create<ConstantOp>(
+ loc, rewriter.getI32VectorAttr(
+ llvm::to_vector<4>(llvm::seq<int32_t>(0, dim))));
idxType = rewriter.getI32Type();
} else {
- SmallVector<int64_t, 4> values(dim);
- for (int64_t d = 0; d < dim; d++)
- values[d] = d;
- indices =
- rewriter.create<ConstantOp>(loc, rewriter.getI64VectorAttr(values));
+ indices = rewriter.create<ConstantOp>(
+ loc, rewriter.getI64VectorAttr(
+ llvm::to_vector<4>(llvm::seq<int64_t>(0, dim))));
idxType = rewriter.getI64Type();
}
// Add in an offset if requested.
@@ -451,11 +447,9 @@ class VectorGatherOpConversion : public ConvertToLLVMPattern {
return failure();
// Replace with the gather intrinsic.
- ValueRange v = (llvm::size(adaptor.pass_thru()) == 0) ? ValueRange({})
- : adaptor.pass_thru();
rewriter.replaceOpWithNewOp<LLVM::masked_gather>(
- gather, typeConverter.convertType(vType), ptrs, adaptor.mask(), v,
- rewriter.getI32IntegerAttr(align));
+ gather, typeConverter.convertType(vType), ptrs, adaptor.mask(),
+ adaptor.pass_thru(), rewriter.getI32IntegerAttr(align));
return success();
}
};
@@ -1282,7 +1276,7 @@ class VectorTransferConversion : public ConvertToLLVMPattern {
// dimensions here.
unsigned vecWidth = vecTy.getVectorNumElements();
unsigned lastIndex = llvm::size(xferOp.indices()) - 1;
- Value off = *(xferOp.indices().begin() + lastIndex);
+ Value off = xferOp.indices()[lastIndex];
Value dim = rewriter.create<DimOp>(loc, xferOp.memref(), lastIndex);
Value mask = buildVectorComparison(rewriter, op, enableIndexOptimizations,
vecWidth, dim, &off);
More information about the Mlir-commits
mailing list