Simplify the logic of getting hold of a PHI predecessor block.

There is now a direct way from value-use-iterator to incoming block in PHINode's API.
This way we avoid the iterator->index->iterator trip, and especially the costly
getOperandNo() invocation. Additionally there is now an assertion that the iterator
really refers to one of the PHI's Uses.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62869 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Gabor Greif
2009-01-23 19:40:15 +00:00
parent 60789e419e
commit a36791da41
6 changed files with 14 additions and 12 deletions

View File

@@ -459,8 +459,7 @@ static bool OptimizeNoopCopyExpression(CastInst *CI, const TargetLowering &TLI){
// appropriate predecessor block.
BasicBlock *UserBB = User->getParent();
if (PHINode *PN = dyn_cast<PHINode>(User)) {
unsigned OpVal = UI.getOperandNo()/2;
UserBB = PN->getIncomingBlock(OpVal);
UserBB = PN->getIncomingBlock(UI);
}
// Preincrement use iterator so we don't invalidate it.