+ // Check that the predecessor is qualified to take the hoisted
+ // instruction. I.e., there is only one edge from the predecessor, and it's to
+ // the loop header.
+ MachineBasicBlock *MBB = Preds.front();
+
+ // FIXME: We are assuming at first that the basic blocks coming into this loop
+ // have only one successor each. This isn't the case in general because we
+ // haven't broken critical edges or added preheaders.
+ if (MBB->succ_size() != 1) return;
+ assert(*MBB->succ_begin() == CurLoop->getHeader() &&
+ "The predecessor doesn't feed directly into the loop header!");
+
+ // Now move the instructions to the predecessor.
+ MoveInstToEndOfBlock(MBB, MI.clone());
+
+ // Hoisting was successful! Remove bothersome instruction now.
+ MI.getParent()->remove(&MI);