diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2010-01-21 07:03:21 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2010-01-21 07:03:21 +0000 |
commit | 9e26c1cc0c48bf9fed270ec9d6abdb46fbc8114c (patch) | |
tree | da8235bf04c810efecc694dc15761ffc347a9d94 /llvm/lib/VMCore/ConstantFold.cpp | |
parent | f2f73bf214a0b4ce7b3dc62de98144b6b00e2e05 (diff) | |
download | bcm5719-llvm-9e26c1cc0c48bf9fed270ec9d6abdb46fbc8114c.tar.gz bcm5719-llvm-9e26c1cc0c48bf9fed270ec9d6abdb46fbc8114c.zip |
Fix a crasher trying to fold each element in a comparison between two vectors
if one of the vectors didn't have elements (such as undef). Fixes PR 6096.
Fix an issue in the constant folder where fcmp (<2 x %ty>, <2 x %ty>) would
have <2 x i1> type if constant folding was successful and i1 type if it wasn't.
This exposed a related issue in the bitcode reader.
llvm-svn: 94069
Diffstat (limited to 'llvm/lib/VMCore/ConstantFold.cpp')
-rw-r--r-- | llvm/lib/VMCore/ConstantFold.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/VMCore/ConstantFold.cpp b/llvm/lib/VMCore/ConstantFold.cpp index 3a24389134e..ddd55878cb9 100644 --- a/llvm/lib/VMCore/ConstantFold.cpp +++ b/llvm/lib/VMCore/ConstantFold.cpp @@ -1673,14 +1673,15 @@ Constant *llvm::ConstantFoldCompareInstruction(LLVMContext &Context, SmallVector<Constant*, 16> C1Elts, C2Elts; C1->getVectorElements(Context, C1Elts); C2->getVectorElements(Context, C2Elts); + if (C1Elts.empty() || C2Elts.empty()) + return 0; // If we can constant fold the comparison of each element, constant fold // the whole vector comparison. SmallVector<Constant*, 4> ResElts; for (unsigned i = 0, e = C1Elts.size(); i != e; ++i) { // Compare the elements, producing an i1 result or constant expr. - ResElts.push_back( - ConstantExpr::getCompare(pred, C1Elts[i], C2Elts[i])); + ResElts.push_back(ConstantExpr::getCompare(pred, C1Elts[i], C2Elts[i])); } return ConstantVector::get(&ResElts[0], ResElts.size()); } |