[Mlir-commits] [mlir] emit inbounds and nuw attributes in memref. (PR #138984)
Andrzej WarzyĆski
llvmlistbot at llvm.org
Mon May 19 11:25:06 PDT 2025
================
@@ -829,9 +829,13 @@ struct LoadOpLowering : public LoadStoreOpLowering<memref::LoadOp> {
ConversionPatternRewriter &rewriter) const override {
auto type = loadOp.getMemRefType();
- Value dataPtr =
- getStridedElementPtr(loadOp.getLoc(), type, adaptor.getMemref(),
- adaptor.getIndices(), rewriter);
+ // Per memref.load spec, the indices must be in-bounds:
+ // 0 <= idx < dim_size, and additionally all offsets are non-negative,
+ // hence inbounds and nuw are used when lowering to llvm.getelementptr.
----------------
banach-space wrote:
Why not extract this comment and `LLVM::GEPNoWrapFlags::inbounds | LLVM::GEPNoWrapFlags::nuw` is a static constant within this file? This way you will avoid duplication and improve re-use.
https://github.com/llvm/llvm-project/pull/138984
More information about the Mlir-commits
mailing list