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 | c2783009b33fec3a6f68e9153dbd3f73dade03eb (patch) | |
tree | 810e0829a62f9b6d599f423d1a32e97cf482a731 | |
parent | 185de449591d400a25976029efcce7baef34a411 (diff) | |
download | bcm5719-llvm-c2783009b33fec3a6f68e9153dbd3f73dade03eb.tar.gz bcm5719-llvm-c2783009b33fec3a6f68e9153dbd3f73dade03eb.zip |
Fix ConstantFoldShuffleVectorInstruction to properly handle the case
when the result type has a different # elements than the input vectors.
llvm-svn: 149221
-rw-r--r-- | llvm/lib/VMCore/ConstantFold.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/llvm/lib/VMCore/ConstantFold.cpp b/llvm/lib/VMCore/ConstantFold.cpp index 36bd4aba4b1..f73e7a76d1a 100644 --- a/llvm/lib/VMCore/ConstantFold.cpp +++ b/llvm/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; |