RFC: Support "saturate" arithmetic ops

I would like to lower arithmetic operations into saturated llvm intrinsics.
To do so, I want to add some “saturated” attribute to the relevant arithmetic ops, and to change their lowering to consider this flag.
Does this change sound reasonable and desired?

Hi Omri, welcome to the MLIR community.

I’d recommend adding new operations rather than changing the lowering of existing operations like add.

The reason here is that the semantics of an operation go far beyond its lowering – for example you want constant folding and lowering to be in sync so the behavior of your code doesn’t change based on whether an expression is constant folded or not.


I see. OK, thank you very much!