undef beats zero. Fix this missed optimization opportunity. Patch by Matt Elder!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59705 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Nick Lewycky 2008-11-20 04:36:13 +00:00
parent ee85bbcae1
commit d433904982

View File

@ -281,7 +281,7 @@ static Constant *FoldBitCast(Constant *C, const Type *DestTy,
Constant *llvm::ConstantFoldInstruction(Instruction *I, const TargetData *TD) { Constant *llvm::ConstantFoldInstruction(Instruction *I, const TargetData *TD) {
if (PHINode *PN = dyn_cast<PHINode>(I)) { if (PHINode *PN = dyn_cast<PHINode>(I)) {
if (PN->getNumIncomingValues() == 0) if (PN->getNumIncomingValues() == 0)
return Constant::getNullValue(PN->getType()); return UndefValue::get(PN->getType());
Constant *Result = dyn_cast<Constant>(PN->getIncomingValue(0)); Constant *Result = dyn_cast<Constant>(PN->getIncomingValue(0));
if (Result == 0) return 0; if (Result == 0) return 0;