From: Jakub Staszak Date: Fri, 2 Sep 2011 17:01:40 +0000 (+0000) Subject: Return undef value (instead of arbitrary) for wrong or undef index in X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=8370d91f1e70837a60653027aabcd27cea0a2e73;p=oota-llvm.git Return undef value (instead of arbitrary) for wrong or undef index in ConstantVector. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139007 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp index 458f224575c..30bae7162ce 100644 --- a/lib/VMCore/ConstantFold.cpp +++ b/lib/VMCore/ConstantFold.cpp @@ -763,12 +763,12 @@ Constant *llvm::ConstantFoldExtractElementInstruction(Constant *Val, if (ConstantInt *CIdx = dyn_cast(Idx)) { uint64_t Index = CIdx->getZExtValue(); if (Index >= CVal->getNumOperands()) - // ee({w,x,y,z}, wrong_value) -> w (an arbitrary value). - return CVal->getOperand(0); + // ee({w,x,y,z}, wrong_value) -> undef + return UndefValue::get(cast(Val->getType())->getElementType()); return CVal->getOperand(CIdx->getZExtValue()); } else if (isa(Idx)) { - // ee({w,x,y,z}, undef) -> w (an arbitrary value). - return CVal->getOperand(0); + // ee({w,x,y,z}, undef) -> undef + return UndefValue::get(cast(Val->getType())->getElementType()); } } return 0;