Should linalg.indexed_generic allow for affine operations on its body?

Thank you for the reply and links to the other discussion.

Similar to the author of the post, we would like to use as much as possible of the optimization infrastructure implemented in the affine dialect.

I expect that analysis/optimizations of the affine dialect do not reason well about scf.if or std.select,cmpi (implementing affine.max,min). Is this correct?

That would be our use case.

It was a bit counter intuitive to have -convert-linalg-to-affine-loops failing because the body of the generic_indexed was using an affine.if op. Considering that linalg.generic_indexed ops already use affine_map<> to describe iterations/access and has an implemented lowering to affine, I was expecting it to work.

Uhmm… so I should not be using -convert-linalg-to-affine-loops?

Yes! This makes total sense. I am not following all sparse discussions, but do you think that supporting affine.if,max,min would interact poorly with with these new (sparse) representations? Why would it be different with the suggested arith.affine_apply/min/max.

I will investigate this solution and see if results on better optimizations down the line.

I look forward to learn more about this work.