[PATCH] D100102: [VPlan] Use incoming VPValue to detect in-loop reductions (NFC).
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 31 08:49:58 PDT 2021
fhahn updated this revision to Diff 363301.
fhahn added a comment.
rebased after the other phi handling refactoring patches landed. The patch now just updates the tail folding handling for reduction values to iterate over the phis in the VPlan and use VPReductionPHIRecipe directly. This reduces some late callbacks to Legal and the cost model, as well as a call to getOrAddVPValue(), which could become out-of-date after VPlan transformations.
ping :)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D100102/new/
https://reviews.llvm.org/D100102
Files:
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
Index: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
===================================================================
--- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -9405,15 +9405,19 @@
// Finally, if tail is folded by masking, introduce selects between the phi
// and the live-out instruction of each reduction, at the end of the latch.
- if (CM.foldTailByMasking() && !Legal->getReductionVars().empty()) {
+ if (CM.foldTailByMasking()) {
Builder.setInsertPoint(VPBB);
- auto *Cond = RecipeBuilder.createBlockInMask(OrigLoop->getHeader(), Plan);
- for (auto &Reduction : Legal->getReductionVars()) {
- if (CM.isInLoopReduction(Reduction.first))
+ VPValue *Cond = nullptr;
+
+ for (VPRecipeBase &R : Plan->getEntry()->getEntryBasicBlock()->phis()) {
+ VPReductionPHIRecipe *PhiR = dyn_cast<VPReductionPHIRecipe>(&R);
+ if (!PhiR || PhiR->isInLoop())
continue;
- VPValue *Phi = Plan->getOrAddVPValue(Reduction.first);
- VPValue *Red = Plan->getOrAddVPValue(Reduction.second.getLoopExitInstr());
- Builder.createNaryOp(Instruction::Select, {Cond, Red, Phi});
+ if (!Cond)
+ Cond = RecipeBuilder.createBlockInMask(OrigLoop->getHeader(), Plan);
+ VPValue *Red = Plan->getOrAddVPValue(
+ PhiR->getRecurrenceDescriptor().getLoopExitInstr());
+ Builder.createNaryOp(Instruction::Select, {Cond, Red, PhiR});
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100102.363301.patch
Type: text/x-patch
Size: 1476 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210731/fed98409/attachment.bin>
More information about the llvm-commits
mailing list