[Mlir-commits] [mlir] [mlir][SCFToSPIRV] Fix iter_args returning undef on zero trip scf.for (PR #206280)

Arseniy Obolenskiy llvmlistbot at llvm.org
Tue Jul 28 04:36:41 PDT 2026


================
@@ -214,6 +214,16 @@ struct ForOpConversion final : SCFToSPIRVPattern<scf::ForOp> {
       initTypes.push_back(arg.getType());
     replaceSCFOutputValue(forOp, loopOp, rewriter, scfToSPIRVContext,
                           initTypes);
+
+    // Store init values so a zero-trip loop returns them instead of undef.
+    // Skip the stores if the loop is known to always execute at least once.
+    std::optional<APInt> tripCount = forOp.getStaticTripCount();
----------------
aobolensk wrote:

That makes sense, added, thanks!

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


More information about the Mlir-commits mailing list