diff options
author | Sanjay Patel <spatel@rotateright.com> | 2020-04-11 10:05:49 -0400 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2020-04-11 10:05:49 -0400 |
commit | 1318ddbc14c28eee63df9cfe3ed92dca82557935 (patch) | |
tree | e13355c78f4c44e3bc40f9ad942dbcfb270cffc5 /llvm/lib/Analysis/VectorUtils.cpp | |
parent | adb456b8d32feaa65b2ea6f800ea55f5a3c3bcc7 (diff) | |
download | llvm-1318ddbc14c28eee63df9cfe3ed92dca82557935.zip llvm-1318ddbc14c28eee63df9cfe3ed92dca82557935.tar.gz llvm-1318ddbc14c28eee63df9cfe3ed92dca82557935.tar.bz2 |
[VectorUtils] rename scaleShuffleMask to narrowShuffleMaskElts; NFC
As proposed in D77881, we'll have the related widening operation,
so this name becomes too vague.
While here, change the function signature to take an 'int' rather
than 'size_t' for the scaling factor, add an assert for overflow of
32-bits, and improve the documentation comments.
Diffstat (limited to 'llvm/lib/Analysis/VectorUtils.cpp')
-rw-r--r-- | llvm/lib/Analysis/VectorUtils.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/llvm/lib/Analysis/VectorUtils.cpp b/llvm/lib/Analysis/VectorUtils.cpp index 5468794..a5fa3ec 100644 --- a/llvm/lib/Analysis/VectorUtils.cpp +++ b/llvm/lib/Analysis/VectorUtils.cpp @@ -398,8 +398,8 @@ bool llvm::isSplatValue(const Value *V, int Index, unsigned Depth) { return false; } -void llvm::scaleShuffleMask(size_t Scale, ArrayRef<int> Mask, - SmallVectorImpl<int> &ScaledMask) { +void llvm::narrowShuffleMaskElts(int Scale, ArrayRef<int> Mask, + SmallVectorImpl<int> &ScaledMask) { assert(Scale > 0 && "Unexpected scaling factor"); // Fast-path: if no scaling, then it is just a copy. @@ -409,9 +409,15 @@ void llvm::scaleShuffleMask(size_t Scale, ArrayRef<int> Mask, } ScaledMask.clear(); - for (int MaskElt : Mask) - for (int ScaleElt = 0; ScaleElt != (int)Scale; ++ScaleElt) - ScaledMask.push_back(MaskElt < 0 ? MaskElt : Scale * MaskElt + ScaleElt); + for (int MaskElt : Mask) { + if (MaskElt >= 0) { + assert(((uint64_t)Scale * MaskElt + (Scale - 1)) <= + std::numeric_limits<int32_t>::max() && + "Overflowed 32-bits"); + } + for (int SliceElt = 0; SliceElt != Scale; ++SliceElt) + ScaledMask.push_back(MaskElt < 0 ? MaskElt : Scale * MaskElt + SliceElt); + } } MapVector<Instruction *, uint64_t> |