summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/ConstantFold.cpp
diff options
context:
space:
mode:
authorJakub Staszak <jstaszak@apple.com>2011-09-02 17:01:40 +0000
committerJakub Staszak <jstaszak@apple.com>2011-09-02 17:01:40 +0000
commit59a1de1c9dbb4685f74ed6f762dddf9cc06ab172 (patch)
treee63309087b94a9d47880e2317f319d824d7cdbd6 /llvm/lib/VMCore/ConstantFold.cpp
parent057d423e4b7b25c2cea8195d306aea9e70fbf8b0 (diff)
downloadbcm5719-llvm-59a1de1c9dbb4685f74ed6f762dddf9cc06ab172.tar.gz
bcm5719-llvm-59a1de1c9dbb4685f74ed6f762dddf9cc06ab172.zip
Return undef value (instead of arbitrary) for wrong or undef index in
ConstantVector. llvm-svn: 139007
Diffstat (limited to 'llvm/lib/VMCore/ConstantFold.cpp')
-rw-r--r--llvm/lib/VMCore/ConstantFold.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/llvm/lib/VMCore/ConstantFold.cpp b/llvm/lib/VMCore/ConstantFold.cpp
index 458f224575c..30bae7162ce 100644
--- a/llvm/lib/VMCore/ConstantFold.cpp
+++ b/llvm/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;
OpenPOWER on IntegriCloud