[RFC] Range analysis when evaluting/lowering affine maps

I’d be curious to hear more about this, actually (in another thread, maybe), especially if many of them are similar problems to the one you have encountered here.

This sounds like a good idea, and which would be more generic than just “the value is non-negative”. I’m not familiar with the AffineMap structure itself, but perhaps this info can be added there.

Alternatively, the lower bound and upper bound attributes could be propagated to the generated ops, and then a second pass can apply them (e.g. ceildivsi where lowerBound >= 0 just becomes ceildivui). Wherever the data is stored, I think that inferring the ranges, lowering affine, and applying them should be separate (and thus composable).

Related: there has been a lot of discussion about attributes in passes (On querying an Operation's intrinsic (core) vs external/user-defined attributes for example) and I personally would like to see more passes use attributes to annotate metadata.