@@ -1621,32 +1621,27 @@ bool llvm::sortPtrAccesses(ArrayRef<Value *> VL, Type *ElemTy,
1621
1621
auto Compare = llvm::less_first ();
1622
1622
std::set<DistOrdPair, decltype (Compare)> Offsets (Compare);
1623
1623
Offsets.emplace (0 , 0 );
1624
- int Cnt = 1 ;
1625
1624
bool IsConsecutive = true ;
1626
- for (auto * Ptr : VL. drop_front ( )) {
1625
+ for (auto [Idx, Ptr] : drop_begin (enumerate(VL) )) {
1627
1626
std::optional<int > Diff = getPointersDiff (ElemTy, Ptr0, ElemTy, Ptr, DL, SE,
1628
1627
/* StrictCheck=*/ true );
1629
1628
if (!Diff)
1630
1629
return false ;
1631
1630
1632
1631
// Check if the pointer with the same offset is found.
1633
1632
int64_t Offset = *Diff;
1634
- auto Res = Offsets.emplace (Offset, Cnt );
1635
- if (!Res. second )
1633
+ auto [It, IsInserted] = Offsets.emplace (Offset, Idx );
1634
+ if (!IsInserted )
1636
1635
return false ;
1637
1636
// Consecutive order if the inserted element is the last one.
1638
- IsConsecutive = IsConsecutive && std::next (Res.first ) == Offsets.end ();
1639
- ++Cnt;
1637
+ IsConsecutive &= std::next (It) == Offsets.end ();
1640
1638
}
1641
1639
SortedIndices.clear ();
1642
1640
if (!IsConsecutive) {
1643
1641
// Fill SortedIndices array only if it is non-consecutive.
1644
1642
SortedIndices.resize (VL.size ());
1645
- Cnt = 0 ;
1646
- for (const std::pair<int64_t , int > &Pair : Offsets) {
1647
- SortedIndices[Cnt] = Pair.second ;
1648
- ++Cnt;
1649
- }
1643
+ for (auto [Idx, Off] : enumerate(Offsets))
1644
+ SortedIndices[Idx] = Off.second ;
1650
1645
}
1651
1646
return true ;
1652
1647
}
@@ -2639,7 +2634,7 @@ void LoopAccessInfo::analyzeLoop(AAResults *AA, LoopInfo *LI,
2639
2634
SymbolicStrides, UncomputablePtr, false );
2640
2635
if (!CanDoRTIfNeeded) {
2641
2636
auto *I = dyn_cast_or_null<Instruction>(UncomputablePtr);
2642
- recordAnalysis (" CantIdentifyArrayBounds" , I)
2637
+ recordAnalysis (" CantIdentifyArrayBounds" , I)
2643
2638
<< " cannot identify array bounds" ;
2644
2639
LLVM_DEBUG (dbgs () << " LAA: We can't vectorize because we can't find "
2645
2640
<< " the array bounds.\n " );
0 commit comments