[Mlir-commits] [flang] [mlir] [flang] Emit llvm.assume for array bounds constraints (PR #178811)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Fri Jan 30 02:59:49 PST 2026


================
@@ -773,6 +773,17 @@ amendOperationImpl(Operation &op, ArrayRef<llvm::Instruction *> instructions,
       inst->setMetadata(llvm::LLVMContext::MD_mmra, mmraMd);
     return success();
   }
+
+  // Handle llvm.array_bounds attribute - marks assumes as array bounds checks
+  // that should be dropped before vectorization.
+  if (name == "llvm.array_bounds") {
+    llvm::LLVMContext &ctx = moduleTranslation.getLLVMContext();
+    llvm::MDNode *md = llvm::MDNode::get(ctx, {});
+    for (llvm::Instruction *inst : instructions)
+      inst->setMetadata("llvm.array.bounds", md);
+    return success();
+  }
+
----------------
jeanPerier wrote:

Please add a test for the array_bounds propagation from LLVM IR dialect to LLVM IR in mlir/test/Target/LLVMIR (I know the flang test is exercising this code too, but someone updating MLIR code only should not have to rely on flang tests).

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


More information about the Mlir-commits mailing list