diff options
author | Chris Lattner <sabre@nondot.org> | 2012-01-30 05:34:13 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2012-01-30 05:34:13 +0000 |
commit | 0cd0d8149278782aaa93c190f81e04f10a4efb5e (patch) | |
tree | 597378fec36763872bda64ef7bbc2b0549701291 /lib/VMCore | |
parent | 90fb059222f71b334c7dd7221eb8091200d829ef (diff) | |
download | external_llvm-0cd0d8149278782aaa93c190f81e04f10a4efb5e.zip external_llvm-0cd0d8149278782aaa93c190f81e04f10a4efb5e.tar.gz external_llvm-0cd0d8149278782aaa93c190f81e04f10a4efb5e.tar.bz2 |
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
Diffstat (limited to 'lib/VMCore')
-rw-r--r-- | lib/VMCore/ConstantFold.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp index 36bd4ab..f73e7a7 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; |