Given a region R, this transformation will essentially turn R into:
if (...) {
R;
} else {
duplicate_of_R;
}
or alternatively to:
switch(...) {
case ...:
R;
break;
default:
duplicate_of_R;
break;
In both cases the value of the boolean guard or integer switch selector does not matter given that the branches are semantically equivalent.
The code after the duplicated region will need to use an OpPhi to capture ids generated by R and used after R.