diff options
author | Robert Lougher <rob.lougher@gmail.com> | 2014-09-22 11:54:38 +0000 |
---|---|---|
committer | Robert Lougher <rob.lougher@gmail.com> | 2014-09-22 11:54:38 +0000 |
commit | 6da8a243f91a54096927b566d43665427a18a6cb (patch) | |
tree | 2005b805b8120ec28d6fc59d078e46c1389c6db5 /llvm/lib/Target/X86/Utils/X86ShuffleDecode.cpp | |
parent | 14f97d0017c4d5d1b3879d3d6c520c9caccf79ea (diff) | |
download | llvm-6da8a243f91a54096927b566d43665427a18a6cb.zip llvm-6da8a243f91a54096927b566d43665427a18a6cb.tar.gz llvm-6da8a243f91a54096927b566d43665427a18a6cb.tar.bz2 |
Fix assert when decoding PSHUFB mask
The PSHUFB mask decode routine used to assert if the mask index was out of
range (<0 or greater than the size of the vector). The problem is, we can
legitimately have a PSHUFB with a large index using intrinsics. The
instruction only uses the least significant 4 bits. This change removes the
assert and masks the index to match the instruction behaviour.
llvm-svn: 218242
Diffstat (limited to 'llvm/lib/Target/X86/Utils/X86ShuffleDecode.cpp')
-rw-r--r-- | llvm/lib/Target/X86/Utils/X86ShuffleDecode.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/llvm/lib/Target/X86/Utils/X86ShuffleDecode.cpp b/llvm/lib/Target/X86/Utils/X86ShuffleDecode.cpp index 51d251e..6d42a10 100644 --- a/llvm/lib/Target/X86/Utils/X86ShuffleDecode.cpp +++ b/llvm/lib/Target/X86/Utils/X86ShuffleDecode.cpp @@ -247,9 +247,8 @@ void DecodePSHUFBMask(const ConstantDataSequential *C, if (Element & (1 << 7)) ShuffleMask.push_back(SM_SentinelZero); else { - int Index = Base + Element; - assert((Index >= 0 && Index < NumElements) && - "Out of bounds shuffle index for pshub instruction!"); + // Only the least significant 4 bits of the byte are used. + int Index = Base + (Element & 0xf); ShuffleMask.push_back(Index); } } @@ -266,9 +265,8 @@ void DecodePSHUFBMask(ArrayRef<uint64_t> RawMask, if (M & (1 << 7)) ShuffleMask.push_back(SM_SentinelZero); else { - int Index = Base + M; - assert((Index >= 0 && (unsigned)Index < RawMask.size()) && - "Out of bounds shuffle index for pshub instruction!"); + // Only the least significant 4 bits of the byte are used. + int Index = Base + (M & 0xf); ShuffleMask.push_back(Index); } } |