diff options
author | Craig Topper <craig.topper@gmail.com> | 2011-11-29 07:49:05 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@gmail.com> | 2011-11-29 07:49:05 +0000 |
commit | 36e36ace77cf84d7c8326957925550624b3fc89c (patch) | |
tree | d765b1b9b9819b4c4e7014d39c7a1500a4b209f3 /lib/Target/X86/Utils | |
parent | 5d2f8c31556b6a5ce29d2cad314bc48af879c5b3 (diff) | |
download | external_llvm-36e36ace77cf84d7c8326957925550624b3fc89c.zip external_llvm-36e36ace77cf84d7c8326957925550624b3fc89c.tar.gz external_llvm-36e36ace77cf84d7c8326957925550624b3fc89c.tar.bz2 |
Fix issues in shuffle decoding around VPERM* instructions. Fix shuffle decoding for VSHUFPS/D for 256-bit types. Add pattern matching for memory forms of VPERMILPS/VPERMILPD.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145390 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/X86/Utils')
-rw-r--r-- | lib/Target/X86/Utils/X86ShuffleDecode.cpp | 32 | ||||
-rw-r--r-- | lib/Target/X86/Utils/X86ShuffleDecode.h | 4 |
2 files changed, 23 insertions, 13 deletions
diff --git a/lib/Target/X86/Utils/X86ShuffleDecode.cpp b/lib/Target/X86/Utils/X86ShuffleDecode.cpp index f6c9d7b..cf1c55e 100644 --- a/lib/Target/X86/Utils/X86ShuffleDecode.cpp +++ b/lib/Target/X86/Utils/X86ShuffleDecode.cpp @@ -128,17 +128,27 @@ void DecodePUNPCKHMask(unsigned NElts, } } -void DecodeSHUFPSMask(unsigned NElts, unsigned Imm, - SmallVectorImpl<unsigned> &ShuffleMask) { - // Part that reads from dest. - for (unsigned i = 0; i != NElts/2; ++i) { - ShuffleMask.push_back(Imm % NElts); - Imm /= NElts; - } - // Part that reads from src. - for (unsigned i = 0; i != NElts/2; ++i) { - ShuffleMask.push_back(Imm % NElts + NElts); - Imm /= NElts; +void DecodeSHUFPMask(EVT VT, unsigned Imm, + SmallVectorImpl<unsigned> &ShuffleMask) { + unsigned NumElts = VT.getVectorNumElements(); + + unsigned NumLanes = VT.getSizeInBits() / 128; + unsigned NumLaneElts = NumElts / NumLanes; + + int NewImm = Imm; + for (unsigned l = 0; l < NumLanes; ++l) { + unsigned LaneStart = l * NumLaneElts; + // Part that reads from dest. + for (unsigned i = 0; i != NumLaneElts/2; ++i) { + ShuffleMask.push_back(NewImm % NumLaneElts + LaneStart); + NewImm /= NumLaneElts; + } + // Part that reads from src. + for (unsigned i = 0; i != NumLaneElts/2; ++i) { + ShuffleMask.push_back(NewImm % NumLaneElts + NumElts + LaneStart); + NewImm /= NumLaneElts; + } + if (NumLaneElts == 4) NewImm = Imm; // reload imm } } diff --git a/lib/Target/X86/Utils/X86ShuffleDecode.h b/lib/Target/X86/Utils/X86ShuffleDecode.h index 35f6530..48b9ef2 100644 --- a/lib/Target/X86/Utils/X86ShuffleDecode.h +++ b/lib/Target/X86/Utils/X86ShuffleDecode.h @@ -64,8 +64,8 @@ void DecodePUNPCKLMask(EVT VT, void DecodePUNPCKHMask(unsigned NElts, SmallVectorImpl<unsigned> &ShuffleMask); -void DecodeSHUFPSMask(unsigned NElts, unsigned Imm, - SmallVectorImpl<unsigned> &ShuffleMask); +void DecodeSHUFPMask(EVT VT, unsigned Imm, + SmallVectorImpl<unsigned> &ShuffleMask); /// DecodeUNPCKHPMask - This decodes the shuffle masks for unpckhps/unpckhpd /// etc. VT indicates the type of the vector allowing it to handle different |