diff options
author | Jakub Staszak <jstaszak@apple.com> | 2011-09-02 15:43:43 +0000 |
---|---|---|
committer | Jakub Staszak <jstaszak@apple.com> | 2011-09-02 15:43:43 +0000 |
commit | 057d423e4b7b25c2cea8195d306aea9e70fbf8b0 (patch) | |
tree | f93a2c218e548a8592f8276161a312f5a1ee1664 /llvm/lib/VMCore/ConstantFold.cpp | |
parent | 7470fb01d00e559eb9bed5fe00ba7feeb427d5f9 (diff) | |
download | bcm5719-llvm-057d423e4b7b25c2cea8195d306aea9e70fbf8b0.tar.gz bcm5719-llvm-057d423e4b7b25c2cea8195d306aea9e70fbf8b0.zip |
ConstantVector returns arbitrary value for the wrong index.
This fixes PR10813.
llvm-svn: 139006
Diffstat (limited to 'llvm/lib/VMCore/ConstantFold.cpp')
-rw-r--r-- | llvm/lib/VMCore/ConstantFold.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/VMCore/ConstantFold.cpp b/llvm/lib/VMCore/ConstantFold.cpp index 47c693b0306..458f224575c 100644 --- a/llvm/lib/VMCore/ConstantFold.cpp +++ b/llvm/lib/VMCore/ConstantFold.cpp @@ -761,6 +761,10 @@ Constant *llvm::ConstantFoldExtractElementInstruction(Constant *Val, if (ConstantVector *CVal = dyn_cast<ConstantVector>(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); return CVal->getOperand(CIdx->getZExtValue()); } else if (isa<UndefValue>(Idx)) { // ee({w,x,y,z}, undef) -> w (an arbitrary value). |