diff options
author | Chris Lattner <sabre@nondot.org> | 2012-01-26 02:51:13 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2012-01-26 02:51:13 +0000 |
commit | cf12970bd0ae061efca85f7d28829410c94bfc5a (patch) | |
tree | f0188b5640bdbbb7b9f013075e5c84d2e0869742 /llvm/lib/VMCore/ConstantFold.cpp | |
parent | 24e9afff4345b331c8eab721741c3d6cf6600bbf (diff) | |
download | bcm5719-llvm-cf12970bd0ae061efca85f7d28829410c94bfc5a.tar.gz bcm5719-llvm-cf12970bd0ae061efca85f7d28829410c94bfc5a.zip |
eliminate the Constant::getVectorElements method. There are better (and
more robust) ways to do what it was doing now. Also, add static methods
for decoding a ShuffleVector mask.
llvm-svn: 149028
Diffstat (limited to 'llvm/lib/VMCore/ConstantFold.cpp')
-rw-r--r-- | llvm/lib/VMCore/ConstantFold.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/llvm/lib/VMCore/ConstantFold.cpp b/llvm/lib/VMCore/ConstantFold.cpp index 9a3a99164e7..abc019ff4e0 100644 --- a/llvm/lib/VMCore/ConstantFold.cpp +++ b/llvm/lib/VMCore/ConstantFold.cpp @@ -1697,20 +1697,20 @@ Constant *llvm::ConstantFoldCompareInstruction(unsigned short pred, R==APFloat::cmpEqual); } } else if (C1->getType()->isVectorTy()) { - SmallVector<Constant*, 16> C1Elts, C2Elts; - C1->getVectorElements(C1Elts); - C2->getVectorElements(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; // Compare the elements, producing an i1 result or constant expr. - for (unsigned i = 0, e = C1Elts.size(); i != e; ++i) - ResElts.push_back(ConstantExpr::getCompare(pred, C1Elts[i], C2Elts[i])); - - return ConstantVector::get(ResElts); + for (unsigned i = 0, e = C1->getType()->getVectorNumElements(); i != e;++i){ + Constant *C1E = C1->getAggregateElement(i); + Constant *C2E = C2->getAggregateElement(i); + if (C1E == 0 || C2E == 0) break; + + ResElts.push_back(ConstantExpr::getCompare(pred, C1E, C2E)); + } + + if (ResElts.size() == C1->getType()->getVectorNumElements()) + return ConstantVector::get(ResElts); } if (C1->getType()->isFloatingPointTy()) { |