summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2011-05-19 00:37:32 +0000
committerEli Friedman <eli.friedman@gmail.com>2011-05-19 00:37:32 +0000
commit2f1e9e618c459037c358e13193939af2096f176b (patch)
tree74864f6f48a077e8dfe7f108c833732b61991021 /clang/lib/CodeGen
parente376938e93baa6bc0617efdc146526b660fccbbc (diff)
downloadbcm5719-llvm-2f1e9e618c459037c358e13193939af2096f176b.tar.gz
bcm5719-llvm-2f1e9e618c459037c358e13193939af2096f176b.zip
Make __builtin_shufflevector and -ftrapv work correctly together. PR9945.
llvm-svn: 131611
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGExprScalar.cpp16
1 files changed, 5 insertions, 11 deletions
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp
index abc375871f3..fcada3a92ad 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -758,19 +758,13 @@ Value *ScalarExprEmitter::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
Value* V2 = CGF.EmitScalarExpr(E->getExpr(1));
// Handle vec3 special since the index will be off by one for the RHS.
+ const llvm::VectorType *VTy = cast<llvm::VectorType>(V1->getType());
llvm::SmallVector<llvm::Constant*, 32> indices;
for (unsigned i = 2; i < E->getNumSubExprs(); i++) {
- llvm::Constant *C = cast<llvm::Constant>(CGF.EmitScalarExpr(E->getExpr(i)));
- const llvm::VectorType *VTy = cast<llvm::VectorType>(V1->getType());
- if (VTy->getNumElements() == 3) {
- if (llvm::ConstantInt *CI = dyn_cast<llvm::ConstantInt>(C)) {
- uint64_t cVal = CI->getZExtValue();
- if (cVal > 3) {
- C = llvm::ConstantInt::get(C->getType(), cVal-1);
- }
- }
- }
- indices.push_back(C);
+ unsigned Idx = E->getShuffleMaskIdx(CGF.getContext(), i-2);
+ if (VTy->getNumElements() == 3 && Idx > 3)
+ Idx -= 1;
+ indices.push_back(Builder.getInt32(Idx));
}
Value *SV = llvm::ConstantVector::get(indices);
OpenPOWER on IntegriCloud