1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 12:43:36 +01:00

[SLP][NFC]Refactor findLaneForValue and make it static member, NFC, by

V.Dmitriev.

Reduces number of arguments
This commit is contained in:
Alexey Bataev 2021-07-02 10:12:41 -07:00
parent 0afbe610f0
commit be387ac2ae

View File

@ -1768,6 +1768,17 @@ private:
setOperations(S); setOperations(S);
return true; return true;
} }
/// When ReuseShuffleIndices is empty it just returns position of \p V
/// within vector of Scalars. Otherwise, try to remap on its reuse index.
int findLaneForValue(Value *V) const {
unsigned FoundLane = std::distance(Scalars.begin(), find(Scalars, V));
assert(FoundLane < Scalars.size() && "Couldn't find extract lane");
if (!ReuseShuffleIndices.empty()) {
FoundLane = std::distance(ReuseShuffleIndices.begin(),
find(ReuseShuffleIndices, FoundLane));
}
return FoundLane;
}
#ifndef NDEBUG #ifndef NDEBUG
/// Debug printer. /// Debug printer.
@ -2589,17 +2600,6 @@ void BoUpSLP::buildTree(ArrayRef<Value *> Roots,
buildTree(Roots, ExternallyUsedValues, UserIgnoreLst); buildTree(Roots, ExternallyUsedValues, UserIgnoreLst);
} }
static int findLaneForValue(ArrayRef<Value *> Scalars,
ArrayRef<int> ReuseShuffleIndices, Value *V) {
unsigned FoundLane = std::distance(Scalars.begin(), find(Scalars, V));
assert(FoundLane < Scalars.size() && "Couldn't find extract lane");
if (!ReuseShuffleIndices.empty()) {
FoundLane = std::distance(ReuseShuffleIndices.begin(),
find(ReuseShuffleIndices, FoundLane));
}
return FoundLane;
}
void BoUpSLP::buildTree(ArrayRef<Value *> Roots, void BoUpSLP::buildTree(ArrayRef<Value *> Roots,
ExtraValueToDebugLocsMap &ExternallyUsedValues, ExtraValueToDebugLocsMap &ExternallyUsedValues,
ArrayRef<Value *> UserIgnoreLst) { ArrayRef<Value *> UserIgnoreLst) {
@ -2620,8 +2620,7 @@ void BoUpSLP::buildTree(ArrayRef<Value *> Roots,
// For each lane: // For each lane:
for (int Lane = 0, LE = Entry->Scalars.size(); Lane != LE; ++Lane) { for (int Lane = 0, LE = Entry->Scalars.size(); Lane != LE; ++Lane) {
Value *Scalar = Entry->Scalars[Lane]; Value *Scalar = Entry->Scalars[Lane];
int FoundLane = int FoundLane = Entry->findLaneForValue(Scalar);
findLaneForValue(Entry->Scalars, Entry->ReuseShuffleIndices, Scalar);
// Check if the scalar is externally used as an extra arg. // Check if the scalar is externally used as an extra arg.
auto ExtI = ExternallyUsedValues.find(Scalar); auto ExtI = ExternallyUsedValues.find(Scalar);
@ -4681,7 +4680,7 @@ BoUpSLP::isGatherShuffledEntry(const TreeEntry *TE, SmallVectorImpl<int> &Mask,
continue; continue;
unsigned Idx = UsedValuesEntry.lookup(V); unsigned Idx = UsedValuesEntry.lookup(V);
const TreeEntry *VTE = Entries[Idx]; const TreeEntry *VTE = Entries[Idx];
int FoundLane = findLaneForValue(VTE->Scalars, VTE->ReuseShuffleIndices, V); int FoundLane = VTE->findLaneForValue(V);
Mask[I] = Idx * VF + FoundLane; Mask[I] = Idx * VF + FoundLane;
// Extra check required by isSingleSourceMaskImpl function (called by // Extra check required by isSingleSourceMaskImpl function (called by
// ShuffleVectorInst::isSingleSourceMask). // ShuffleVectorInst::isSingleSourceMask).
@ -4847,13 +4846,7 @@ Value *BoUpSLP::gather(ArrayRef<Value *> VL) {
// Add to our 'need-to-extract' list. // Add to our 'need-to-extract' list.
if (TreeEntry *Entry = getTreeEntry(V)) { if (TreeEntry *Entry = getTreeEntry(V)) {
// Find which lane we need to extract. // Find which lane we need to extract.
unsigned FoundLane = unsigned FoundLane = Entry->findLaneForValue(V);
std::distance(Entry->Scalars.begin(), find(Entry->Scalars, V));
assert(FoundLane < Entry->Scalars.size() && "Couldn't find extract lane");
if (!Entry->ReuseShuffleIndices.empty()) {
FoundLane = std::distance(Entry->ReuseShuffleIndices.begin(),
find(Entry->ReuseShuffleIndices, FoundLane));
}
ExternalUses.emplace_back(V, InsElt, FoundLane); ExternalUses.emplace_back(V, InsElt, FoundLane);
} }
return Vec; return Vec;