summaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGExprScalar.cpp
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@gmail.com>2013-08-03 17:40:38 +0000
committerCraig Topper <craig.topper@gmail.com>2013-08-03 17:40:38 +0000
commit6f4f8083931a92f9959168d4430da7ddf9183100 (patch)
tree407d3975378c3ece851f4a166b8ad4c0f0840968 /lib/CodeGen/CGExprScalar.cpp
parenta1c50a1f55086cda654a903abd4ce1908e580faa (diff)
downloadclang-6f4f8083931a92f9959168d4430da7ddf9183100.tar.gz
clang-6f4f8083931a92f9959168d4430da7ddf9183100.tar.bz2
clang-6f4f8083931a92f9959168d4430da7ddf9183100.tar.xz
Add support for passing -1 to __builtin_shufflevector to signify an undefined element value to match IR capabilities.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187694 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExprScalar.cpp')
-rw-r--r--lib/CodeGen/CGExprScalar.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp
index 9ab111c493..b6bda28471 100644
--- a/lib/CodeGen/CGExprScalar.cpp
+++ b/lib/CodeGen/CGExprScalar.cpp
@@ -955,8 +955,12 @@ Value *ScalarExprEmitter::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
SmallVector<llvm::Constant*, 32> indices;
for (unsigned i = 2; i < E->getNumSubExprs(); ++i) {
- unsigned Idx = E->getShuffleMaskIdx(CGF.getContext(), i-2);
- indices.push_back(Builder.getInt32(Idx));
+ llvm::APSInt Idx = E->getShuffleMaskIdx(CGF.getContext(), i-2);
+ // Check for -1 and output it as undef in the IR.
+ if (Idx.isSigned() && Idx.isAllOnesValue())
+ indices.push_back(llvm::UndefValue::get(CGF.Int32Ty));
+ else
+ indices.push_back(Builder.getInt32(Idx.getZExtValue()));
}
Value *SV = llvm::ConstantVector::get(indices);