summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2012-01-30 05:34:13 +0000
committerChris Lattner <sabre@nondot.org>2012-01-30 05:34:13 +0000
commit0cd0d8149278782aaa93c190f81e04f10a4efb5e (patch)
tree597378fec36763872bda64ef7bbc2b0549701291
parent90fb059222f71b334c7dd7221eb8091200d829ef (diff)
downloadllvm-0cd0d8149278782aaa93c190f81e04f10a4efb5e.tar.gz
llvm-0cd0d8149278782aaa93c190f81e04f10a4efb5e.tar.bz2
llvm-0cd0d8149278782aaa93c190f81e04f10a4efb5e.tar.xz
Fix ConstantFoldShuffleVectorInstruction to properly handle the case
when the result type has a different # elements than the input vectors. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149221 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/VMCore/ConstantFold.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp
index 36bd4aba4b..f73e7a76d1 100644
--- a/lib/VMCore/ConstantFold.cpp
+++ b/lib/VMCore/ConstantFold.cpp
@@ -794,15 +794,17 @@ Constant *llvm::ConstantFoldInsertElementInstruction(Constant *Val,
Constant *llvm::ConstantFoldShuffleVectorInstruction(Constant *V1,
Constant *V2,
Constant *Mask) {
+ unsigned MaskNumElts = Mask->getType()->getVectorNumElements();
+ Type *EltTy = V1->getType()->getVectorElementType();
+
// Undefined shuffle mask -> undefined value.
- if (isa<UndefValue>(Mask)) return UndefValue::get(V1->getType());
+ if (isa<UndefValue>(Mask))
+ return UndefValue::get(VectorType::get(EltTy, MaskNumElts));
// Don't break the bitcode reader hack.
if (isa<ConstantExpr>(Mask)) return 0;
- unsigned MaskNumElts = Mask->getType()->getVectorNumElements();
unsigned SrcNumElts = V1->getType()->getVectorNumElements();
- Type *EltTy = V1->getType()->getVectorElementType();
// Loop over the shuffle mask, evaluating each element.
SmallVector<Constant*, 32> Result;