[MLIR][Affine] Simplify nested modulo operations when able
It is the case that, for all positive a and b such that b divides a (e mod (a * b)) mod b = e mod b. For example, ((d0 mod 35) mod 5) can be simplified to (d0 mod 5), but ((d0 mod 35) mod 4) cannot be simplified further (x = 36 is a counterexample). This change enables more complex simplifications. For example, ((d0 * 72 + d1) mod 144) mod 9 can now simplify to (d0 * 72 + d1) mod 9 and thus to d1 mod 9. Expressions with chained modulus operators are reasonably common in tensor applications, and this change _should_ improve code generation for such expressions. Reviewed By: nicolasvasilache Differential Revision: https://reviews.llvm.org/D109930
Loading
Please register or sign in to comment