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:
parent
0afbe610f0
commit
be387ac2ae
@ -1768,6 +1768,17 @@ private:
|
||||
setOperations(S);
|
||||
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
|
||||
/// Debug printer.
|
||||
@ -2589,17 +2600,6 @@ void BoUpSLP::buildTree(ArrayRef<Value *> Roots,
|
||||
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,
|
||||
ExtraValueToDebugLocsMap &ExternallyUsedValues,
|
||||
ArrayRef<Value *> UserIgnoreLst) {
|
||||
@ -2620,8 +2620,7 @@ void BoUpSLP::buildTree(ArrayRef<Value *> Roots,
|
||||
// For each lane:
|
||||
for (int Lane = 0, LE = Entry->Scalars.size(); Lane != LE; ++Lane) {
|
||||
Value *Scalar = Entry->Scalars[Lane];
|
||||
int FoundLane =
|
||||
findLaneForValue(Entry->Scalars, Entry->ReuseShuffleIndices, Scalar);
|
||||
int FoundLane = Entry->findLaneForValue(Scalar);
|
||||
|
||||
// Check if the scalar is externally used as an extra arg.
|
||||
auto ExtI = ExternallyUsedValues.find(Scalar);
|
||||
@ -4681,7 +4680,7 @@ BoUpSLP::isGatherShuffledEntry(const TreeEntry *TE, SmallVectorImpl<int> &Mask,
|
||||
continue;
|
||||
unsigned Idx = UsedValuesEntry.lookup(V);
|
||||
const TreeEntry *VTE = Entries[Idx];
|
||||
int FoundLane = findLaneForValue(VTE->Scalars, VTE->ReuseShuffleIndices, V);
|
||||
int FoundLane = VTE->findLaneForValue(V);
|
||||
Mask[I] = Idx * VF + FoundLane;
|
||||
// Extra check required by isSingleSourceMaskImpl function (called by
|
||||
// ShuffleVectorInst::isSingleSourceMask).
|
||||
@ -4847,13 +4846,7 @@ Value *BoUpSLP::gather(ArrayRef<Value *> VL) {
|
||||
// Add to our 'need-to-extract' list.
|
||||
if (TreeEntry *Entry = getTreeEntry(V)) {
|
||||
// Find which lane we need to extract.
|
||||
unsigned FoundLane =
|
||||
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));
|
||||
}
|
||||
unsigned FoundLane = Entry->findLaneForValue(V);
|
||||
ExternalUses.emplace_back(V, InsElt, FoundLane);
|
||||
}
|
||||
return Vec;
|
||||
|
Loading…
Reference in New Issue
Block a user