Of course there was something missing, in this case a check that the def of the count register we are adding to a t2DoLoopStartTP would dominate the insertion point.
In the future, when we remove some of these COPY's in between, the t2DoLoopStartTP will always become the last instruction in the block, preventing this from happening. In the meantime we need to check they are created in a sensible order.
If it doesn't dominate, we're saying that the def is actually the last instruction in the block, right? So can't we make InsertPt = MBB->end()?