// We have two instructions of identical opcode and #operands. Check to see
// if all operands are the same.
- for (unsigned i = 0, e = getNumOperands(); i != e; ++i)
- if (getOperand(i) != I->getOperand(i))
- return false;
+ if (!std::equal(op_begin(), op_end(), I->op_begin()))
+ return false;
// Check special state that is a part of some instructions.
if (const LoadInst *LI = dyn_cast<LoadInst>(this))
RMWI->getSynchScope() == cast<AtomicRMWInst>(I)->getSynchScope();
if (const PHINode *thisPHI = dyn_cast<PHINode>(this)) {
const PHINode *otherPHI = cast<PHINode>(I);
- for (unsigned i = 0, e = thisPHI->getNumOperands(); i != e; ++i) {
- if (thisPHI->getIncomingBlock(i) != otherPHI->getIncomingBlock(i))
- return false;
- }
- return true;
+ return std::equal(thisPHI->block_begin(), thisPHI->block_end(),
+ otherPHI->block_begin());
}
return true;
}
// new one.
SmallVector<std::pair<unsigned, MDNode*>, 4> TheMDs;
getAllMetadataOtherThanDebugLoc(TheMDs);
- for (unsigned i = 0, e = TheMDs.size(); i != e; ++i)
- New->setMetadata(TheMDs[i].first, TheMDs[i].second);
+ for (const auto &MD : TheMDs)
+ New->setMetadata(MD.first, MD.second);
New->setDebugLoc(getDebugLoc());
return New;