MaxGraey wrote: In LLVM, I think Reassoc or OptimizeAndOrXor passes handles this. But that might be a bit of overkill for simple canonicalization in MLIR. Right now, it tries fold until fix-point is reached with limit to 10 iterations. https://github.com/llvm/llvm-project/pull/195588