-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Promote 32bit pseudo instr that infer extsw removal to 64bit in PPCMIPeephole #85451
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 16 commits
79aaf13
d4b4abc
affb9bf
75494c3
489cccc
1ece68c
56b04f5
692138b
95267f5
4482b29
8e98ab8
9b0b9c8
8550317
9a4e4d0
3798b03
34b52bb
f0cdc75
1de4b40
9ae473b
910b1b5
095acfc
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 | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -5234,6 +5234,218 @@ bool PPCInstrInfo::isTOCSaveMI(const MachineInstr &MI) const { | |||||||
| // We limit the max depth to track incoming values of PHIs or binary ops | ||||||||
| // (e.g. AND) to avoid excessive cost. | ||||||||
| const unsigned MAX_BINOP_DEPTH = 1; | ||||||||
|
|
||||||||
| // This function will promote the instruction which defines the register `Reg` | ||||||||
| // in the parameter from a 32-bit to a 64-bit instruction if needed. The logic | ||||||||
| // used to check whether an instruction needs to be promoted or not is similar | ||||||||
| // to the logic used to check whether or not a defined register is sign or zero | ||||||||
| // extended within the function PPCInstrInfo::isSignOrZeroExtended. | ||||||||
| // Additionally, the `promoteInstr32To64ForElimEXTSW` function is recursive. | ||||||||
| // BinOpDepth does not count all of the recursions. The parameter BinOpDepth is | ||||||||
| // incremented only when `promoteInstr32To64ForElimEXTSW` calls itself more | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From what I can see below,
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good Catch for AND8 . the logic of BinOpDepth is come from function isSignOrZeroExtended(), when the instructions(e.g., AND, PHI, OR) which has two or more source registers , the instructions which defines these source registers also need to be promoted and so on , without increase the BinOpDepth , it maybe have 2 * 2 * 2 * 2.... recursions of promoteInstr32To64ForElimEXTSW. |
||||||||
| // than once. This is done to prevent exponential recursion. | ||||||||
| void PPCInstrInfo::promoteInstr32To64ForElimEXTSW(const Register &Reg, | ||||||||
| MachineRegisterInfo *MRI, | ||||||||
| unsigned BinOpDepth, | ||||||||
| LiveVariables *LV) const { | ||||||||
| if (!Reg.isVirtual()) | ||||||||
| return; | ||||||||
|
|
||||||||
| MachineInstr *MI = MRI->getVRegDef(Reg); | ||||||||
| if (!MI) | ||||||||
| return; | ||||||||
|
|
||||||||
| unsigned Opcode = MI->getOpcode(); | ||||||||
| bool IsNonSignedExtInstrNeedPromoted = false; | ||||||||
|
||||||||
| int NewOpcode = -1; | ||||||||
|
|
||||||||
| #define MapOpCode(A) \ | ||||||||
| case A: \ | ||||||||
| NewOpcode = A##8; \ | ||||||||
| IsNonSignedExtInstrNeedPromoted = true; \ | ||||||||
| break | ||||||||
|
|
||||||||
| switch (Opcode) { | ||||||||
| MapOpCode(PPC::OR); | ||||||||
| MapOpCode(PPC::ISEL); | ||||||||
| MapOpCode(PPC::ORI); | ||||||||
| MapOpCode(PPC::XORI); | ||||||||
| MapOpCode(PPC::ORIS); | ||||||||
| MapOpCode(PPC::XORIS); | ||||||||
| MapOpCode(PPC::AND); | ||||||||
| } | ||||||||
| #undef MapOpCode | ||||||||
|
|
||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: remove empty line |
||||||||
| switch (Opcode) { | ||||||||
lei137 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
| case PPC::OR: | ||||||||
| case PPC::ISEL: | ||||||||
| case PPC::OR8: | ||||||||
| case PPC::PHI: | ||||||||
| if (BinOpDepth < MAX_BINOP_DEPTH) { | ||||||||
|
||||||||
| if (BinOpDepth < MAX_BINOP_DEPTH) { | |
| if (BinOpDepth >= MAX_BINOP_DEPTH) | |
| break; |
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.
We should copy the explanation comments for these conditions from issignorzeroextended() as well
Outdated
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.
no need for tmp var. Can inline into call.
Outdated
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.
brace not needed here.
Outdated
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.
tmp var SrcReg[12] is not needed. Prefer to inline it into the call.
amy-kwan marked this conversation as resolved.
Show resolved
Hide resolved
amy-kwan marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
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.
Is Reg updated anywhere above? I don't see seem to see any updates so am a bit confused why this check is here vs at the top. Can we add a comment here as to why we are exiting earlier?
nit: remove empty line 5350
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.
we can not move the checking to top, because even the RegClass of the reg is PPC::G8RCRegClass or PPC::G8RC_and_G8RC_NOX0RegClass , we still need to check whether we need to logic in the switch statement
for example, COPY from PPC::GPRCRegClass to PPC::G8RCRegClass, we still need to do promoteInstr32To64ForElimEXTSW
Outdated
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 the indentation from here to return is a bit off.
Uh oh!
There was an error while loading. Please reload this page.