-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[Xtensa] Implement branch analysis. #110959
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
Conversation
case Xtensa::BGEI: | ||
case Xtensa::BGEUI: | ||
return MI.getOperand(2).getMBB(); | ||
|
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.
Unnecessary empty lines
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.
Currently this code is removed as redundant.
bool XtensaInstrInfo::analyzeBranch(MachineBasicBlock &MBB, | ||
MachineBasicBlock *&TBB, | ||
MachineBasicBlock *&FBB, | ||
SmallVectorImpl<MachineOperand> &Cond, | ||
bool AllowModify = false) const { |
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 family of functions should be implemented independently of branch relaxation. They're more used for branch folding
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.
Thank you for comment. Is it ok if I will correct this PR and remove branch relaxation functionality? The PR then will contain only branch analysis implementation.
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.
sure
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.
Corrected
// FIXME: A virtual register must be used initially, as the register | ||
// scavenger won't work with empty blocks (SIInstrInfo::insertIndirectBranch | ||
// uses the same workaround). | ||
Register ScratchReg = MRI.createVirtualRegister(&Xtensa::ARRegClass); |
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 think this got fixed actually. The workaround might still be there though
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.
Currently this code is removed as redundant.
4df5a20
to
2b1a8b1
Compare
const DebugLoc &DL, | ||
int *BytesAdded = nullptr) const override; | ||
|
||
unsigned InsertBranchAtInst(MachineBasicBlock &MBB, |
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.
Start with lowercase
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.
Corrected
if (I->isDebugValue()) | ||
continue; |
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.
Untested?
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 prepared new test which checks analyzeBranch and reverseBranchCondition functionality. I hope I understand your comment correctly.
case Xtensa::BLTUI: | ||
Cond[0].setImm(Xtensa::BGEUI); | ||
return false; | ||
|
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.
Inconsistent blank lines here and a few other places
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.
corrected
SmallVectorImpl<MachineOperand> &Cond) const { | ||
assert(Cond.size() <= 4 && "Invalid branch condition!"); | ||
|
||
switch (Cond[0].getImm()) { |
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.
Not sure all of these are tested?
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 tested most of cases for reverseBranchCondition and it seems it works correctly.
No description provided.