[Mlir-commits] [mlir] [mlir][SCFToSPIRV] Fix iter_args returning undef on zero trip scf.for (PR #206280)
Igor Wodiany
llvmlistbot at llvm.org
Tue Jul 28 04:07:08 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();
----------------
IgWod wrote:
Should we also add a test for the case where `tripCount` is not static?
https://github.com/llvm/llvm-project/pull/206280
More information about the Mlir-commits
mailing list