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

Kohei Yamaguchi llvmlistbot at llvm.org
Sat Oct 31 08:48:53 PDT 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, agreed. I removed the extra  flag. The loop emitter now selects sparse levels as the iteration drivers, so a single sparse level still produces an  even when dense levels are also present. Encoded dense levels are tracked separately to preserve the iterator state needed by their child sparse levels. I also added regression tests for the mixed sparse/dense-parent case and the dense/synthetic-only fallback.

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


More information about the Mlir-commits mailing list