diff --git a/lib/Transforms/Scalar/TailDuplication.cpp b/lib/Transforms/Scalar/TailDuplication.cpp index 17237431a91..e736f970af5 100644 --- a/lib/Transforms/Scalar/TailDuplication.cpp +++ b/lib/Transforms/Scalar/TailDuplication.cpp @@ -303,7 +303,7 @@ Value *TailDup::GetValueInBlock(BasicBlock *BB, Value *OrigVal, } // Found a value to replace the PHI node with? - if (ReplVal) { + if (ReplVal && ReplVal != PN) { PN->replaceAllUsesWith(ReplVal); BBVal = ReplVal; if (BBOutVal == PN) BBOutVal = ReplVal;