[PATCH] D149627: [NFC][SLP] Cleanup: Simplify traversal loop in SLPVectorizerPass::vectorizeHorReduction().
Alexey Bataev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 3 04:29:21 PDT 2023
ABataev added inline comments.
================
Comment at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:14029-14033
+ // If we can find a secondary reduction root, use that instead.
+ Instruction *NewRoot = nullptr;
+ if (isReductionCandidate(Root) && TryOperandsAsNewSeeds &&
+ HorizontalReduction::getRdxKind(Root) != RecurKind::None)
+ NewRoot = tryGetSecondaryReductionRoot(P, Root);
----------------
Can you turn into lambda too:
```
auto SelectRoot = [&]() {
if (TryOperandsAsNewSeeds && isReductionCandidate(Root) &&
HorizontalReduction::getRdxKind(Root) != RecurKind::None)
return tryGetSecondaryReductionRoot(P, Root);
return Root;
}
...
Stack.emplace(SelectRoot(), 0);
```
================
Comment at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:14031
+ Instruction *NewRoot = nullptr;
+ if (isReductionCandidate(Root) && TryOperandsAsNewSeeds &&
+ HorizontalReduction::getRdxKind(Root) != RecurKind::None)
----------------
`TryOperandsAsNewSeeds && isReductionCandidate(Root) &&` to avoid extra call when TryOperandsAsNewSeeds is false.
================
Comment at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:14060-14061
+ };
+ auto TryAppendToPostponedInsts = [TryOperandsAsNewSeeds, Root, P,
+ &PostponedInsts](Instruction *FutureSeed) {
+ if (TryOperandsAsNewSeeds && FutureSeed == Root) {
----------------
`auto TryAppendToPostponedInsts = [&]`
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D149627/new/
https://reviews.llvm.org/D149627
More information about the llvm-commits
mailing list