You have a getUsers() on Operation which allows to directly iterates on this nested loop (see inline edit)
Nit: no need for braces here.
and you can likely just assign() here:
rewriter.mergeBlocks will do the splicing, but at the end.
Nit: .front() would avoid derefencing an iterator (may just be more readable)
Just like the other revision: there are far too much back() (and even back().back()!) here, I'd like to see some refactoring into better accessors.
Can you use llvm::enumerate instead of a side indexing?
Ah OK I see the logic, it is actually moving and preserving the block itself. And we need this because the else region can be empty but not the then one.