-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[VPlan] Fold common edges away in convertPhisToBlends #150368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
4505704
1fd1624
be337df
7af8137
b058933
704d77e
9cf075c
7f3e453
f6a68e7
d4e3066
82d7105
c712745
5df080c
6c1d674
7fa9d54
6502634
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -14,6 +14,7 @@ | |||||
| #include "VPRecipeBuilder.h" | ||||||
| #include "VPlan.h" | ||||||
| #include "VPlanCFG.h" | ||||||
| #include "VPlanPatternMatch.h" | ||||||
| #include "VPlanTransforms.h" | ||||||
| #include "VPlanUtils.h" | ||||||
| #include "llvm/ADT/PostOrderIterator.h" | ||||||
|
|
@@ -65,6 +66,10 @@ class VPPredicator { | |||||
| return EdgeMaskCache[{Src, Dst}] = Mask; | ||||||
| } | ||||||
|
|
||||||
| /// Given a widened phi \p PhiR, try to see if its incoming blocks all share a | ||||||
| /// common edge and return its mask. | ||||||
| VPValue *findCommonEdgeMask(const VPWidenPHIRecipe *PhiR) const; | ||||||
|
|
||||||
| public: | ||||||
| /// Returns the precomputed predicate of the edge from \p Src to \p Dst. | ||||||
| VPValue *getEdgeMask(const VPBasicBlock *Src, const VPBasicBlock *Dst) const { | ||||||
|
|
@@ -226,6 +231,20 @@ void VPPredicator::createSwitchEdgeMasks(VPInstruction *SI) { | |||||
| setEdgeMask(Src, DefaultDst, DefaultMask); | ||||||
| } | ||||||
|
|
||||||
| VPValue *VPPredicator::findCommonEdgeMask(const VPWidenPHIRecipe *PhiR) const { | ||||||
| using namespace llvm::VPlanPatternMatch; | ||||||
|
||||||
| VPValue *EdgeMask = getEdgeMask(PhiR->getIncomingBlock(0), PhiR->getParent()); | ||||||
| VPValue *CommonEdgeMask; | ||||||
| if (!EdgeMask || | ||||||
| !match(EdgeMask, m_LogicalAnd(m_VPValue(CommonEdgeMask), m_VPValue()))) | ||||||
| return nullptr; | ||||||
| for (unsigned In = 1; In < PhiR->getNumIncoming(); In++) | ||||||
|
||||||
| for (unsigned In = 1; In < PhiR->getNumIncoming(); In++) | |
| for (unsigned In : seq<unsigned>(1, PhiR->getNumIncoming())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think seq is used very often in the loop vectorizer. Should we open up a separate patch to look at refactoring things to use it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's okay to just set an example in this instance: contributors will see it, and follow; a refactoring follow-on is optional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Take our clang-format policy for instance: it's okay to have a mostly unformatted file, but we require that our changes are formatted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes but I'm not sure if using seq for regular for loops is part of the loop vectorizer code style to begin with.
I'm aware it's used a lot throughout SLP but I think it would be good to be consistent throughout the loop vectorizer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this now is just a VPPhi, which usually is scalar, i.e. prediction is happening before widening