[PATCH] D36930: [ARM] Factorize the calculation of WhichResult in isV*Mask. NFC.
Martin Storsjö via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 19 12:59:57 PDT 2017
mstorsjo created this revision.
Herald added subscribers: kristof.beyls, javed.absar, aemerson.
https://reviews.llvm.org/D36930
Files:
lib/Target/ARM/ARMISelLowering.cpp
Index: lib/Target/ARM/ARMISelLowering.cpp
===================================================================
--- lib/Target/ARM/ARMISelLowering.cpp
+++ lib/Target/ARM/ARMISelLowering.cpp
@@ -5800,6 +5800,12 @@
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 +5842,7 @@
// 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 +5869,7 @@
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 +5901,7 @@
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 +5932,7 @@
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 +5972,7 @@
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 +6005,7 @@
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) ||
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36930.111851.patch
Type: text/x-patch
Size: 3351 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170819/7d965cae/attachment.bin>
More information about the llvm-commits
mailing list