undef beats zero. Fix this missed optimization opportunity. Patch by Matt Elder!
authorNick Lewycky <nicholas@mxc.ca>
Thu, 20 Nov 2008 04:36:13 +0000 (04:36 +0000)
committerNick Lewycky <nicholas@mxc.ca>
Thu, 20 Nov 2008 04:36:13 +0000 (04:36 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59705 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/ConstantFolding.cpp

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