https://github.com/akroviakov commented: You can outline the body of the parentOp results loop to avoid the core logic duplication and call the body conditionally, supplying corresponding parent ops and values. https://github.com/llvm/llvm-project/pull/202931