[Mlir-commits] [mlir] [MLIR][LLVM] Support inrange in GEP (PR #220424)

Letu Ren llvmlistbot at llvm.org
Sat Sep 12 20:04:17 PDT 2026


================
@@ -907,9 +909,21 @@ DeletionKind LLVM::GEPOp::rewire(const DestructurableMemorySlot &slot,
   const MemorySlot &newSlot = subslots.at(indexAttr);
 
   auto byteType = IntegerType::get(builder.getContext(), 8);
-  auto newPtr = builder.createOrFold<LLVM::GEPOp>(
-      getLoc(), getResult().getType(), byteType, newSlot.ptr,
-      ArrayRef<GEPArg>(accessInfo->subslotOffset), getNoWrapFlags());
+  // `inrange` is relative to the GEP result. The rewired GEP computes the same
+  // address, so the range can be copied as-is. Create the GEP before folding so
+  // a zero-offset GEP is not folded away when that would drop `inrange`.
+  Value newPtr;
+  if (auto inrange = getInrangeAttr()) {
----------------
FantasqueX wrote:

It cannot happen if it is imported from valid llvm ir. However, verifier cannot easily check whether GEPop is a constant expression. It may happen. So, the new version just pass inrange attribute to the new OP.

https://github.com/llvm/llvm-project/pull/220424


More information about the Mlir-commits mailing list