[Mlir-commits] [mlir] [mlir][sparse] Fix mixed sparse-dense iterator lowering (PR #219753)

Kohei Yamaguchi llvmlistbot at llvm.org
Mon Nov 2 22:13:45 PST 2026


================
@@ -1190,14 +1198,18 @@ static void genInitConstantDenseAddress(CodegenEnv &env,
 static bool translateBitsToTidLvlPairs(
     CodegenEnv &env, LatPointId li, LoopId curr,
     SmallVectorImpl<TensorLevel> &tidLvls,
+    SmallVectorImpl<TensorLevel> &condTidLvls,
     SmallVectorImpl<std::pair<TensorLevel, AffineExpr>> &affineTidLvls) {
-  return getAllTidLvlsInLatPoints(env, li, curr,
-                                  [&](TensorLevel tl, AffineExpr exp) {
-                                    if (exp)
-                                      affineTidLvls.emplace_back(tl, exp);
-                                    else
-                                      tidLvls.emplace_back(tl);
-                                  });
+  return getAllTidLvlsInLatPoints(
+      env, li, curr, [&](TensorLevel tl, AffineExpr exp, bool isLoopCond) {
+        if (exp)
+          affineTidLvls.emplace_back(tl, exp);
+        else {
+          tidLvls.emplace_back(tl);
+          if (isLoopCond)
+            condTidLvls.emplace_back(tl);
----------------
sott0n wrote:

Thanks for clarifying. I simplified the change accordingly: Sparsification now passes the translated tid/lvl pairs unchanged, and LoopEmitter recomputes the single SparseTensor-encoded level from those pairs before creating the IterateOp. I removed the dense iterator reconstruction, dense-only SCF fallback, and related tests that were outside this fix.

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


More information about the Mlir-commits mailing list