summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorTim Northover <tnorthover@apple.com>2014-04-18 12:50:58 +0000
committerTim Northover <tnorthover@apple.com>2014-04-18 12:50:58 +0000
commit01f315a556a726d82eb5fbe7eb61ce8084a3374b (patch)
tree811b540e2b52a4fea3d735e2a3253186d277ba4c /llvm/lib
parent191ebd874f0970f3560b2d20cee77b927292479c (diff)
downloadbcm5719-llvm-01f315a556a726d82eb5fbe7eb61ce8084a3374b.tar.gz
bcm5719-llvm-01f315a556a726d82eb5fbe7eb61ce8084a3374b.zip
AArch64/ARM64: improve spotting of EXT instructions from VECTOR_SHUFFLE.
We couldn't cope if the first mask element was UNDEF before, which isn't ideal. llvm-svn: 206588
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/ARM64/ARM64ISelLowering.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/llvm/lib/Target/ARM64/ARM64ISelLowering.cpp b/llvm/lib/Target/ARM64/ARM64ISelLowering.cpp
index efd979b5e2e..503e44b0dc0 100644
--- a/llvm/lib/Target/ARM64/ARM64ISelLowering.cpp
+++ b/llvm/lib/Target/ARM64/ARM64ISelLowering.cpp
@@ -3945,11 +3945,13 @@ static bool isEXTMask(ArrayRef<int> M, EVT VT, bool &ReverseEXT,
unsigned NumElts = VT.getVectorNumElements();
ReverseEXT = false;
- // Assume that the first shuffle index is not UNDEF. Fail if it is.
- if (M[0] < 0)
- return false;
-
- Imm = M[0];
+ // Look for the first non-undef choice and count backwards from
+ // that. E.g. <-1, -1, 3, ...> means that an EXT must start at 3 - 2 = 1. This
+ // guarantees that at least one index is correct.
+ const int *FirstRealElt =
+ std::find_if(M.begin(), M.end(), [](int Elt) { return Elt >= 0; });
+ assert(FirstRealElt != M.end() && "Completely UNDEF shuffle? Why bother?");
+ Imm = *FirstRealElt - (FirstRealElt - M.begin());
// If this is a VEXT shuffle, the immediate value is the index of the first
// element. The other shuffle indices must be the successive elements after
OpenPOWER on IntegriCloud