aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGExprScalar.cpp
diff options
context:
space:
mode:
authorNate Begeman <natebegeman@mac.com>2009-10-25 02:26:01 +0000
committerNate Begeman <natebegeman@mac.com>2009-10-25 02:26:01 +0000
commita99f08351b6df3bb0f2947e038747717a60fd93a (patch)
tree46c14880c49c970cf8a0e1b456e4bfbd273008f9 /lib/CodeGen/CGExprScalar.cpp
parent5c14dcebdece3b2bb70ba0afa01f093676870b14 (diff)
Fix a bug in calculating shufflevector indices when constructing vectors from other vectors.
If I can find it again, I will check in a testcase. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85032 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExprScalar.cpp')
-rw-r--r--lib/CodeGen/CGExprScalar.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp
index 69604f9aaa..c1abeb188d 100644
--- a/lib/CodeGen/CGExprScalar.cpp
+++ b/lib/CodeGen/CGExprScalar.cpp
@@ -678,14 +678,13 @@ Value *ScalarExprEmitter::VisitInitListExpr(InitListExpr *E) {
// If the initializer is an ExtVecEltExpr (a swizzle), and the swizzle's
// input is the same width as the vector being constructed, generate an
// optimized shuffle of the swizzle input into the result.
+ unsigned Offset = (CurIdx == 0) ? 0 : ResElts;
if (isa<ExtVectorElementExpr>(IE)) {
llvm::ShuffleVectorInst *SVI = cast<llvm::ShuffleVectorInst>(Init);
Value *SVOp = SVI->getOperand(0);
const llvm::VectorType *OpTy = cast<llvm::VectorType>(SVOp->getType());
if (OpTy->getNumElements() == ResElts) {
- unsigned Offset = (CurIdx == 0) ? 0 : ResElts;
-
for (unsigned j = 0; j != CurIdx; ++j) {
// If the current vector initializer is a shuffle with undef, merge
// this shuffle directly into it.
@@ -717,13 +716,13 @@ Value *ScalarExprEmitter::VisitInitListExpr(InitListExpr *E) {
Args.push_back(llvm::UndefValue::get(I32Ty));
llvm::Constant *Mask = llvm::ConstantVector::get(&Args[0], ResElts);
Init = Builder.CreateShuffleVector(Init, llvm::UndefValue::get(VVT),
- Mask, "vecext");
+ Mask, "vext");
Args.clear();
for (unsigned j = 0; j != CurIdx; ++j)
Args.push_back(llvm::ConstantInt::get(I32Ty, j));
for (unsigned j = 0; j != InitElts; ++j)
- Args.push_back(llvm::ConstantInt::get(I32Ty, j+ResElts));
+ Args.push_back(llvm::ConstantInt::get(I32Ty, j+Offset));
for (unsigned j = CurIdx + InitElts; j != ResElts; ++j)
Args.push_back(llvm::UndefValue::get(I32Ty));
}