[Mlir-commits] [mlir] [MLIR][LLVM] Support inrange in GEP (PR #220424)
Tobias Gysi
llvmlistbot at llvm.org
Mon Sep 14 12:02:53 PDT 2026
================
@@ -829,6 +829,11 @@ LogicalResult LLVM::GEPOp::verify() {
if (getNoWrapFlags() == GEPNoWrapFlags::inboundsFlag)
return emitOpError("'inbounds_flag' cannot be used directly.");
+ if (auto inrange = getInrangeAttr()) {
+ if (inrange.getLower().sge(inrange.getUpper()))
+ return emitOpError("expected 'inrange' end to be larger than start");
----------------
gysit wrote:
I see. I guess that is one possible design point.
Technically, an imported integer constant should be recognizable in MLIR using:
```
APInt cst;
matchPattern(val, m_ConstantInt(&cst));
```
A verifier would force passes that generate inrange GEPs to provide integer constants rather than some computation that may fold to a constant during export. In that sense having a verifier is slightly more restrictive but it gives the guarantee that the export will not fail.
I am fine with the current solution since the LLVM dialect verifiers are often not on par with the LLVM IR ones. A more restrictive verifier would be an option as well though.
https://github.com/llvm/llvm-project/pull/220424
More information about the Mlir-commits
mailing list