dberlin added a comment. Of course. Just in case you try to use the code, i'm pretty sure if (OrderedInstructions->dominates(*Iter, guard)) should be if (OrderedInstructions->dominates(guard, *Iter)) (At least one of the calls is reversed) https://reviews.llvm.org/D37460