The verifier incorrectly passed the region number of the predecessor region instead of the successor region to getSuccessorOperands. This went unnoticed since all upstream RegionBranchTerminatorOpInterface implementations did not make use of the index parameter.
Adding an assert to e.g. scf.condition to make sure the index is valid or adding a region terminator that passes different operands to different successors immediately causes the verifier to fail as it suddenly gets incorrect types.
This patch fixes the implementation to correctly pass the successor region index.
Depends on https://reviews.llvm.org/D157506
There's no existing test to merge this withj?