[llvm] 7451bf0 - [SLP] use std::distance/find to reduce code; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 21 13:23:08 PDT 2020
Author: Sanjay Patel
Date: 2020-09-21T16:22:55-04:00
New Revision: 7451bf0b0b6d77e9c39408aeedfa3fa90107fe7a
URL: https://github.com/llvm/llvm-project/commit/7451bf0b0b6d77e9c39408aeedfa3fa90107fe7a
DIFF: https://github.com/llvm/llvm-project/commit/7451bf0b0b6d77e9c39408aeedfa3fa90107fe7a.diff
LOG: [SLP] use std::distance/find to reduce code; NFC
We were already using this code pattern right after
the loop, so this makes it consistent.
Added:
Modified:
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index a9fbc7b38a3e..5fad74090489 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -4147,19 +4147,12 @@ Value *BoUpSLP::gather(ArrayRef<Value *> VL) {
// Add to our 'need-to-extract' list.
if (TreeEntry *E = getTreeEntry(VL[i])) {
// Find which lane we need to extract.
- int FoundLane = -1;
- for (unsigned Lane = 0, LE = E->Scalars.size(); Lane != LE; ++Lane) {
- // Is this the lane of the scalar that we are looking for ?
- if (E->Scalars[Lane] == VL[i]) {
- FoundLane = Lane;
- break;
- }
- }
- assert(FoundLane >= 0 && "Could not find the correct lane");
+ unsigned FoundLane =
+ std::distance(E->Scalars.begin(), find(E->Scalars, VL[i]));
+ assert(FoundLane < E->Scalars.size() && "Could not find extract lane");
if (!E->ReuseShuffleIndices.empty()) {
- FoundLane =
- std::distance(E->ReuseShuffleIndices.begin(),
- llvm::find(E->ReuseShuffleIndices, FoundLane));
+ FoundLane = std::distance(E->ReuseShuffleIndices.begin(),
+ find(E->ReuseShuffleIndices, FoundLane));
}
ExternalUses.push_back(ExternalUser(VL[i], Insrt, FoundLane));
}
More information about the llvm-commits
mailing list