diff options
author | Martin Storsjo <martin@martin.st> | 2017-08-19 20:26:51 +0000 |
---|---|---|
committer | Martin Storsjo <martin@martin.st> | 2017-08-19 20:26:51 +0000 |
commit | d606d2a643da45fb1de3475f5987affdf7c7a8bc (patch) | |
tree | b9709ae5a9ebaade9ef7f1bf4fabe3551098f26b /llvm/lib/Target/ARM/ARMISelLowering.cpp | |
parent | ecb94a039291145aab487ba1713f05c3684bc8f4 (diff) | |
download | bcm5719-llvm-d606d2a643da45fb1de3475f5987affdf7c7a8bc.tar.gz bcm5719-llvm-d606d2a643da45fb1de3475f5987affdf7c7a8bc.zip |
[ARM] Factorize the calculation of WhichResult in isV*Mask. NFC.
Differential Revision: https://reviews.llvm.org/D36930
llvm-svn: 311260
Diffstat (limited to 'llvm/lib/Target/ARM/ARMISelLowering.cpp')
-rw-r--r-- | llvm/lib/Target/ARM/ARMISelLowering.cpp | 37 |
1 files changed, 13 insertions, 24 deletions
diff --git a/llvm/lib/Target/ARM/ARMISelLowering.cpp b/llvm/lib/Target/ARM/ARMISelLowering.cpp index 320d7ccfbc2..63a96ccde78 100644 --- a/llvm/lib/Target/ARM/ARMISelLowering.cpp +++ b/llvm/lib/Target/ARM/ARMISelLowering.cpp @@ -5800,6 +5800,13 @@ static bool isVTBLMask(ArrayRef<int> M, EVT VT) { return VT == MVT::v8i8 && M.size() == 8; } +static unsigned SelectPairHalf(unsigned Elements, ArrayRef<int> Mask, + unsigned Index) { + if (Mask.size() == Elements * 2) + return Index / Elements; + return Mask[Index] == 0 ? 0 : 1; +} + // Checks whether the shuffle mask represents a vector transpose (VTRN) by // checking that pairs of elements in the shuffle mask represent the same index // in each vector, incrementing the expected index by 2 at each step. @@ -5836,10 +5843,7 @@ static bool isVTRNMask(ArrayRef<int> M, EVT VT, unsigned &WhichResult) { // element is undefined, e.g. [-1, 4, 2, 6] will be rejected, because only // M[0] is used to determine WhichResult for (unsigned i = 0; i < M.size(); i += NumElts) { - if (M.size() == NumElts * 2) - WhichResult = i / NumElts; - else - WhichResult = M[i] == 0 ? 0 : 1; + WhichResult = SelectPairHalf(NumElts, M, i); for (unsigned j = 0; j < NumElts; j += 2) { if ((M[i+j] >= 0 && (unsigned) M[i+j] != j + WhichResult) || (M[i+j+1] >= 0 && (unsigned) M[i+j+1] != j + NumElts + WhichResult)) @@ -5866,10 +5870,7 @@ static bool isVTRN_v_undef_Mask(ArrayRef<int> M, EVT VT, unsigned &WhichResult){ return false; for (unsigned i = 0; i < M.size(); i += NumElts) { - if (M.size() == NumElts * 2) - WhichResult = i / NumElts; - else - WhichResult = M[i] == 0 ? 0 : 1; + WhichResult = SelectPairHalf(NumElts, M, i); for (unsigned j = 0; j < NumElts; j += 2) { if ((M[i+j] >= 0 && (unsigned) M[i+j] != j + WhichResult) || (M[i+j+1] >= 0 && (unsigned) M[i+j+1] != j + WhichResult)) @@ -5901,10 +5902,7 @@ static bool isVUZPMask(ArrayRef<int> M, EVT VT, unsigned &WhichResult) { return false; for (unsigned i = 0; i < M.size(); i += NumElts) { - if (M.size() == NumElts * 2) - WhichResult = i / NumElts; - else - WhichResult = M[i] == 0 ? 0 : 1; + WhichResult = SelectPairHalf(NumElts, M, i); for (unsigned j = 0; j < NumElts; ++j) { if (M[i+j] >= 0 && (unsigned) M[i+j] != 2 * j + WhichResult) return false; @@ -5935,10 +5933,7 @@ static bool isVUZP_v_undef_Mask(ArrayRef<int> M, EVT VT, unsigned &WhichResult){ unsigned Half = NumElts / 2; for (unsigned i = 0; i < M.size(); i += NumElts) { - if (M.size() == NumElts * 2) - WhichResult = i / NumElts; - else - WhichResult = M[i] == 0 ? 0 : 1; + WhichResult = SelectPairHalf(NumElts, M, i); for (unsigned j = 0; j < NumElts; j += Half) { unsigned Idx = WhichResult; for (unsigned k = 0; k < Half; ++k) { @@ -5978,10 +5973,7 @@ static bool isVZIPMask(ArrayRef<int> M, EVT VT, unsigned &WhichResult) { return false; for (unsigned i = 0; i < M.size(); i += NumElts) { - if (M.size() == NumElts * 2) - WhichResult = i / NumElts; - else - WhichResult = M[i] == 0 ? 0 : 1; + WhichResult = SelectPairHalf(NumElts, M, i); unsigned Idx = WhichResult * NumElts / 2; for (unsigned j = 0; j < NumElts; j += 2) { if ((M[i+j] >= 0 && (unsigned) M[i+j] != Idx) || @@ -6014,10 +6006,7 @@ static bool isVZIP_v_undef_Mask(ArrayRef<int> M, EVT VT, unsigned &WhichResult){ return false; for (unsigned i = 0; i < M.size(); i += NumElts) { - if (M.size() == NumElts * 2) - WhichResult = i / NumElts; - else - WhichResult = M[i] == 0 ? 0 : 1; + WhichResult = SelectPairHalf(NumElts, M, i); unsigned Idx = WhichResult * NumElts / 2; for (unsigned j = 0; j < NumElts; j += 2) { if ((M[i+j] >= 0 && (unsigned) M[i+j] != Idx) || |