jurahul wrote: I realized after I implemented this that existing fold primitives can also implement this (and I see atleast one example in an AMDGPU td file that does this). But this is much easier to use. https://github.com/llvm/llvm-project/pull/109346