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

Letu Ren llvmlistbot at llvm.org
Sat Sep 12 19:56:46 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`.
----------------
FantasqueX wrote:

I forgot to update GEP's builder. Previously, `createOrFold` didn't accept `inrange` attribute. I updated the builder. This issue should have been fixed.

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


More information about the Mlir-commits mailing list