fhahn wrote: Do you think splitting up checking if tail-folding is possible from collecting masked ops would help simplify this change? There's https://github.com/llvm/llvm-project/pull/77612 which I could update if it would help https://github.com/llvm/llvm-project/pull/91403