mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-11-23 00:20:25 +00:00
[DAGCombiner] Add a shuffle mask commutation helper function. NFCI.
We have an increasing number of cases where we are creating commuted shuffle masks - all implementing nearly the same code. This patch adds a static helper function - ShuffleVectorSDNode::commuteMask() and replaces a number of cases to use it. Differential Revision: http://reviews.llvm.org/D8139 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231581 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1332,6 +1332,21 @@ public:
|
||||
}
|
||||
static bool isSplatMask(const int *Mask, EVT VT);
|
||||
|
||||
/// Change values in a shuffle permute mask assuming
|
||||
/// the two vector operands have swapped position.
|
||||
static void commuteMask(SmallVectorImpl<int> &Mask) {
|
||||
unsigned NumElems = Mask.size();
|
||||
for (unsigned i = 0; i != NumElems; ++i) {
|
||||
int idx = Mask[i];
|
||||
if (idx < 0)
|
||||
continue;
|
||||
else if (idx < (int)NumElems)
|
||||
Mask[i] = idx + NumElems;
|
||||
else
|
||||
Mask[i] = idx - NumElems;
|
||||
}
|
||||
}
|
||||
|
||||
static bool classof(const SDNode *N) {
|
||||
return N->getOpcode() == ISD::VECTOR_SHUFFLE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user