Skip to content

Commit

Permalink
[LoopVec] Reuse a lambda [NFC]
Browse files Browse the repository at this point in the history
Minor code refactor to improve readability.
  • Loading branch information
preames committed Nov 24, 2020
1 parent 51994f9 commit 1a9c72f
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
Expand Up @@ -5084,6 +5084,14 @@ void LoopVectorizationCostModel::collectLoopUniforms(ElementCount VF) {
WideningDecision == CM_Widen_Reverse ||
WideningDecision == CM_Interleave);
};


// Returns true if Ptr is the pointer operand of a memory access instruction
// I, and I is known to not require scalarization.
auto isVectorizedMemAccessUse = [&](Instruction *I, Value *Ptr) -> bool {
return getLoadStorePointerOperand(I) == Ptr && isUniformDecision(I, VF);
};

// Iterate over the instructions in the loop, and collect all
// consecutive-like pointer operands in ConsecutiveLikePtrs. If it's possible
// that a consecutive-like pointer operand will be scalarized, we collect it
Expand Down Expand Up @@ -5159,20 +5167,12 @@ void LoopVectorizationCostModel::collectLoopUniforms(ElementCount VF) {
auto *OI = cast<Instruction>(OV);
if (llvm::all_of(OI->users(), [&](User *U) -> bool {
auto *J = cast<Instruction>(U);
return Worklist.count(J) ||
(OI == getLoadStorePointerOperand(J) &&
isUniformDecision(J, VF));
return Worklist.count(J) || isVectorizedMemAccessUse(J, OI);
}))
addToWorklistIfAllowed(OI);
}
}

// Returns true if Ptr is the pointer operand of a memory access instruction
// I, and I is known to not require scalarization.
auto isVectorizedMemAccessUse = [&](Instruction *I, Value *Ptr) -> bool {
return getLoadStorePointerOperand(I) == Ptr && isUniformDecision(I, VF);
};

// For an instruction to be added into Worklist above, all its users inside
// the loop should also be in Worklist. However, this condition cannot be
// true for phi nodes that form a cyclic dependence. We must process phi
Expand Down

0 comments on commit 1a9c72f

Please sign in to comment.