diff options
author | Jakub Staszak <jstaszak@apple.com> | 2011-09-02 17:01:40 +0000 |
---|---|---|
committer | Jakub Staszak <jstaszak@apple.com> | 2011-09-02 17:01:40 +0000 |
commit | 8370d91f1e70837a60653027aabcd27cea0a2e73 (patch) | |
tree | 1ac382f9a2d6468b8d4325d92b9cf3960bd22da3 | |
parent | 4c6b8bee2ab087f3b21efa6b638c6848f23b74d7 (diff) | |
download | external_llvm-8370d91f1e70837a60653027aabcd27cea0a2e73.zip external_llvm-8370d91f1e70837a60653027aabcd27cea0a2e73.tar.gz external_llvm-8370d91f1e70837a60653027aabcd27cea0a2e73.tar.bz2 |
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
-rw-r--r-- | lib/VMCore/ConstantFold.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp index 458f224..30bae71 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<ConstantInt>(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<VectorType>(Val->getType())->getElementType()); return CVal->getOperand(CIdx->getZExtValue()); } else if (isa<UndefValue>(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<VectorType>(Val->getType())->getElementType()); } } return 0; |