* Use `create` instead of `createOrFold` for constant ops. Constants cannot be folded any further.
* Use `create` instead of `createOrFold` for ops that do not have a folder.
* Use C++ op builders that take an `int` instead of creating a `ConstantIndexOp`.
* Create `tensor::DimOp` instead of `linalg::createOrFoldDimOp` when it is certain that the operand is a tensor.
Differential Revision: https://reviews.llvm.org/D154196
static Value createI32Constant(ConversionPatternRewriter &rewriter,
Location loc, int32_t value) {
Type llvmI32 = rewriter.getI32Type();
- return rewriter.createOrFold<LLVM::ConstantOp>(loc, llvmI32, value);
+ return rewriter.create<LLVM::ConstantOp>(loc, llvmI32, value);
}
namespace {
return input;
int64_t numBytes = vectorType.getNumElements();
Type destType = rewriter.getIntegerType(numBytes * 8);
- Value result = rewriter.createOrFold<LLVM::ConstantOp>(
+ Value result = rewriter.create<LLVM::ConstantOp>(
loc, destType, rewriter.getIntegerAttr(destType, 0));
for (int64_t i = 0; i < numBytes; ++i) {
Value idxConst = createI32Constant(rewriter, loc, i);
Value element =
rewriter.create<LLVM::ExtractElementOp>(loc, input, idxConst);
Value extended = rewriter.create<LLVM::ZExtOp>(loc, destType, element);
- Value shiftConst = rewriter.createOrFold<LLVM::ConstantOp>(
+ Value shiftConst = rewriter.create<LLVM::ConstantOp>(
loc, destType, rewriter.getIntegerAttr(destType, i * 8));
Value shifted = rewriter.create<LLVM::ShlOp>(loc, extended, shiftConst);
result = rewriter.create<LLVM::OrOp>(loc, result, shifted);
for (int i = 0; i < memrefType.getRank(); ++i) {
if (!memrefType.isDynamicDim(i))
continue;
- Value size = rewriter.createOrFold<arith::ConstantIndexOp>(loc, i);
- Value dim =
- rewriter.createOrFold<memref::DimOp>(loc, op.getInput(), size);
+ Value dim = rewriter.createOrFold<memref::DimOp>(loc, op.getInput(), i);
dynamicOperands.push_back(dim);
}
affineDimsExpr(rewriter, 0, 1, 2)});
// Width and height dimensions of the original input.
- auto dimH = linalg::createOrFoldDimOp(rewriter, loc, input, 1);
- auto dimW = linalg::createOrFoldDimOp(rewriter, loc, input, 2);
+ auto dimH = rewriter.createOrFold<tensor::DimOp>(loc, input, 1);
+ auto dimW = rewriter.createOrFold<tensor::DimOp>(loc, input, 2);
// Constants and dimension sizes
auto twoPiAttr = rewriter.getFloatAttr(elementType, 6.283185307179586);
for (int i = 0; i < destType.getRank(); ++i) {
if (destType.getShape()[i] != ShapedType::kDynamic)
continue;
- auto index = b.createOrFold<arith::ConstantIndexOp>(loc, i);
- Value size = b.create<memref::DimOp>(loc, value, index);
+ Value size = b.create<memref::DimOp>(loc, value, i);
dynamicOperands.push_back(size);
}
// TODO: Use alloc/memcpy callback from BufferizationOptions if called via
ubs.reserve(lbs.size());
steps.reserve(lbs.size());
for (auto idx = 0; idx < rank; ++idx) {
- ubs.push_back(b.createOrFold<memref::DimOp>(
- from, b.create<arith::ConstantIndexOp>(idx)));
+ ubs.push_back(b.createOrFold<memref::DimOp>(from, idx));
steps.push_back(one);
}
auto staticBufferType =
MemRefType::get(width * cst.value(), b.getIntegerType(8));
if (options.useAlloca) {
- return b.createOrFold<memref::AllocaOp>(staticBufferType, ValueRange{},
- alignmentAttr);
+ return b.create<memref::AllocaOp>(staticBufferType, ValueRange{},
+ alignmentAttr);
}
- return b.createOrFold<memref::AllocOp>(staticBufferType, ValueRange{},
- alignmentAttr);
+ return b.create<memref::AllocOp>(staticBufferType, ValueRange{},
+ alignmentAttr);
}
// Fallback dynamic buffer.
std::optional<unsigned> alignment, DataLayout &layout) {
ShapedType viewType = subView.getType();
ImplicitLocOpBuilder b(subView.getLoc(), builder);
- auto zero = b.createOrFold<arith::ConstantIndexOp>(0);
- auto one = b.createOrFold<arith::ConstantIndexOp>(1);
+ auto zero = b.create<arith::ConstantIndexOp>(0);
+ auto one = b.create<arith::ConstantIndexOp>(1);
Value allocSize = one;
for (const auto &size : llvm::enumerate(boundingSubViewSize))
Location loc = dimOp->getLoc();
rewriter.replaceOpWithNewOp<tensor::ExtractOp>(
dimOp, resultShape,
- rewriter.createOrFold<arith::ConstantIndexOp>(loc, *dimIndex));
+ rewriter.create<arith::ConstantIndexOp>(loc, *dimIndex).getResult());
return success();
}
};