summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/ARM64/ARM64ISelLowering.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/llvm/lib/Target/ARM64/ARM64ISelLowering.cpp b/llvm/lib/Target/ARM64/ARM64ISelLowering.cpp
index a832bd044a4..502ff212bee 100644
--- a/llvm/lib/Target/ARM64/ARM64ISelLowering.cpp
+++ b/llvm/lib/Target/ARM64/ARM64ISelLowering.cpp
@@ -4001,13 +4001,19 @@ static bool isEXTMask(ArrayRef<int> M, EVT VT, bool &ReverseEXT,
// value of the first element.
// E.g. <-1, -1, 3, ...> is treated as <1, 2, 3, ...>.
// <-1, -1, 0, 1, ...> is treated as <IDX, IDX+1, 0, 1, ...>. IDX is
- // equal to the ExpectedElt. For this case, ExpectedElt is (NumElts*2 - 2).
+ // equal to the ExpectedElt.
Imm = (M[0] >= 0) ? static_cast<unsigned>(M[0]) : ExpectedElt.getZExtValue();
- // Adjust the index value if the source operands will be swapped.
- if (Imm >= NumElts) {
+ // If no beginning UNDEFs, do swap when M[0] >= NumElts.
+ if (M[0] >= 0 && Imm >= NumElts) {
ReverseEXT = true;
Imm -= NumElts;
+ } else if (M[0] < 0) {
+ // Only do swap when beginning UNDEFs more than the first real element,
+ if (*FirstRealElt < FirstRealElt - M.begin())
+ ReverseEXT = true;
+ if (Imm >= NumElts)
+ Imm -= NumElts;
}
return true;
OpenPOWER on IntegriCloud