Skip to content

Commit 6b380b0

Browse files
committed
Single loop
1 parent 31ee725 commit 6b380b0

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13436,19 +13436,20 @@ static std::optional<unsigned> isDUPQMask(ArrayRef<int> M, EVT VT) {
1343613436
unsigned Lane = (unsigned)M[0];
1343713437
unsigned Segments = VT.getFixedSizeInBits() / 128;
1343813438
unsigned SegmentElts = VT.getVectorNumElements() / Segments;
13439+
13440+
// Make sure there's no size changes.
1343913441
if (SegmentElts * Segments != M.size())
1344013442
return std::nullopt;
1344113443

13442-
for (unsigned I = 0; I < Segments; ++I) {
13443-
unsigned Broadcast = (unsigned)M[I * SegmentElts];
13444-
if (Broadcast - (I * SegmentElts) > SegmentElts)
13444+
// Check that the first index corresponds to one of the lanes in the first
13445+
// segment.
13446+
if ((unsigned)M[0] >= SegmentElts)
13447+
return std::nullopt;
13448+
13449+
// Check that all lanes match the first, adjusted for segment.
13450+
for (unsigned I = 0; I < M.size(); ++I)
13451+
if ((unsigned)M[I] != ((unsigned)M[0] + ((I / SegmentElts) * SegmentElts)))
1344513452
return std::nullopt;
13446-
for (unsigned J = 0; J < SegmentElts; ++J) {
13447-
int Idx = M[(I * SegmentElts) + J];
13448-
if ((unsigned)Idx != Broadcast)
13449-
return std::nullopt;
13450-
}
13451-
}
1345213453

1345313454
return Lane;
1345413455
}

0 commit comments

Comments
 (0)