Is it possible to generate Affine for loop with multiple index variables. Using below code, able to generate affine for loop with just one index variable.

If you just want a different index, affine.for can have secondary induction variables via its iter_args, but you’ll have to increment or otherwise update them yourself. I also don’t recall if they are considered as dimensions per affine value classification or not.

If you want a “multifor” loop nest, it is not possible with affine.for but is possible with affine.parallel provided all loops are indeed parallel.

Assuming you wanted to write i < a && j < b instead of using the operator comma in the condition, such as loop will have to be an scf.while. Neither Affine nor SCF support such bounds.

You could also write the secondary induction variables in terms of the induction variable of the for loop. In the example you give, you could rewrite it as:

for (i = 0; i < min(a, b); i++) {
j = i;
}

I believe you can do this in general:

for (i = l1, j = l2; i < u1, j < u2; i+= s1, j += s2) {
}
s1 * i + l1 = s2 * j + l2

This is the way I would do it if you really want to use affine loop nests.