-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[llvm][CodeGen] Update checking method of loop-carried phi in window scheduler #96288
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
[llvm][CodeGen] Update checking method of loop-carried phi in window scheduler #96288
Conversation
…scheduler Added some logic to check loop-carried phis in the window scheduler. It now includes the scenario where the preceding phi uses the virtual register defined by the succeeding phi.
Could you please review this patch? Thank you~ @arsenm |
llvm/lib/CodeGen/WindowScheduler.cpp
Outdated
if (!MO.isReg()) | ||
continue; | ||
if (MO.isDef()) { |
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.
You know the structure of phi so you can increment by 2 and check the single def separately
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.
Updated
SmallSet<Register, 8> PrevDefs; | ||
SmallSet<Register, 8> PrevUses; |
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.
These sets aren't used outside of the lambda. Just make the lambda a helper function with these used locally?
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.
These sets are used to record the defs and uses of phis that have already been checked in the current MBB.
They need to be initialized and retain register information across multiple calls to the lambda.
Therefore, wouldn't it be better to place these sets outside the lambda?
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.
ok
SmallSet<Register, 8> PrevDefs; | ||
SmallSet<Register, 8> PrevUses; |
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.
ok
llvm/lib/CodeGen/WindowScheduler.cpp
Outdated
// preceding phi is used by the succeeding phi;(2)The preceding phi uses the | ||
// virtual register defined by the succeeding phi. | ||
auto Def = Phi.getOperand(0); | ||
if (Def.isReg()) { |
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.
Def must be a register. Don't try to handle invalid MIR
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.
Updated
llvm/lib/CodeGen/WindowScheduler.cpp
Outdated
} | ||
for (unsigned I = 1, E = Phi.getNumOperands(); I != E; I += 2) { | ||
auto Use = Phi.getOperand(I); | ||
if (Use.isReg()) { |
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.
Use must be a register
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.
Updated
…scheduler (llvm#96288) Added some logic to check loop-carried phis in the window scheduler. It now includes the scenario where the preceding phi uses the virtual register defined by the succeeding phi.
Added some logic to check loop-carried phis in the window scheduler. It
now includes the scenario where the preceding phi uses the virtual
register defined by the succeeding phi.