diff options
author | Simon Pilgrim <llvm-dev@redking.me.uk> | 2016-05-01 20:43:02 +0000 |
---|---|---|
committer | Simon Pilgrim <llvm-dev@redking.me.uk> | 2016-05-01 20:43:02 +0000 |
commit | ca140b17cb9c2c093ea3e45441091be0bd9e51ac (patch) | |
tree | c13bc995265014edefe214837d3acf7a949858a2 /llvm/lib/Transforms | |
parent | c59049207511e09313fef6bf413b96166883c748 (diff) | |
download | bcm5719-llvm-ca140b17cb9c2c093ea3e45441091be0bd9e51ac.tar.gz bcm5719-llvm-ca140b17cb9c2c093ea3e45441091be0bd9e51ac.zip |
[InstCombine][SSE] Added support to VPERMD/VPERMPS to shuffle combine to accept UNDEF elements.
llvm-svn: 268206
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp index 25f4c768fcd..67fdaced7c4 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp @@ -696,25 +696,30 @@ static Value *simplifyX86vpermv(const IntrinsicInst &II, if (!V) return nullptr; - VectorType *VecTy = cast<VectorType>(II.getType()); + auto *VecTy = cast<VectorType>(II.getType()); + auto *MaskEltTy = Type::getInt32Ty(II.getContext()); unsigned Size = VecTy->getNumElements(); assert(Size == 8 && "Unexpected shuffle mask size"); - // Initialize the resulting shuffle mask to all zeroes. - uint32_t Indexes[8] = {0}; + // Construct a shuffle mask from constant integers or UNDEFs. + Constant *Indexes[8] = {NULL}; for (unsigned I = 0; I < Size; ++I) { Constant *COp = V->getAggregateElement(I); - if (!COp || !isa<ConstantInt>(COp)) + if (!COp || (!isa<UndefValue>(COp) && !isa<ConstantInt>(COp))) return nullptr; + if (isa<UndefValue>(COp)) { + Indexes[I] = UndefValue::get(MaskEltTy); + continue; + } + APInt Index = cast<ConstantInt>(COp)->getValue(); - Index = Index.getLoBits(3); - Indexes[I] = (uint32_t)Index.getZExtValue(); + Index = Index.zextOrTrunc(32).getLoBits(3); + Indexes[I] = ConstantInt::get(MaskEltTy, Index); } - auto ShuffleMask = - ConstantDataVector::get(II.getContext(), makeArrayRef(Indexes, Size)); + auto ShuffleMask = ConstantVector::get(makeArrayRef(Indexes, Size)); auto V1 = II.getArgOperand(0); auto V2 = UndefValue::get(VecTy); return Builder.CreateShuffleVector(V1, V2, ShuffleMask); |