[Mlir-commits] [mlir] [mlir][gpu] Fix crash in transform.gpu.map_nested_forall_to_threads with zero iterations (PR #170282)

Fabian Mora llvmlistbot at llvm.org
Tue Feb 17 04:00:04 PST 2026


================
@@ -141,12 +141,14 @@ std::optional<int64_t> getConstantIntValue(OpFoldResult ofr) {
 std::optional<SmallVector<int64_t>>
 getConstantIntValues(ArrayRef<OpFoldResult> ofrs) {
   bool failed = false;
-  SmallVector<int64_t> res = llvm::map_to_vector(ofrs, [&](OpFoldResult ofr) {
+  SmallVector<int64_t> res;
+  res.reserve(ofrs.size());
+  for (OpFoldResult ofr : ofrs) {
     auto cv = getConstantIntValue(ofr);
     if (!cv.has_value())
       failed = true;
-    return cv.value_or(0);
-  });
+    res.push_back(cv.value_or(0));
+  }
----------------
fabianmcg wrote:

That sounds like a C++ compiler bug, semantically they should produce equivalent results. However, let's assume the code first code is wrong. Let's keep the loop but early return once we now it's going to fail instead of waiting till the end.

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


More information about the Mlir-commits mailing list