-
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 7 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,244 @@ 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; | ||||||||
|
|
||||||||
| // The `PromoteInstr32To64ForEmliEXTSW` function is recursive. The parameter | ||||||||
| // BinOpDepth does not count all of the recursions. The parameter BinOpDepth is | ||||||||
| // incremented only when `PromoteInstr32To64ForEmliEXTSW` calls itself more | ||||||||
| // than once. This is done to prevent exponential recursion. The function will | ||||||||
|
||||||||
| // promote the instruction which defines the register `Reg` in the parameter | ||||||||
| // from a 32-bit to a 64-bit instruction if needed. Additionally, all the used | ||||||||
| // and defined registers in the instruction may also need to be promoted from | ||||||||
| // 32-bit to 64-bit based on the promoted instruction description. If a used | ||||||||
|
||||||||
| // register is promoted to 64-bit, the instruction which defines the promoted | ||||||||
| // register also needs to be promoted. After an instruction is promoted to 64 | ||||||||
| // bits, the defined register of the promoted instruction is also 64-bit. A | ||||||||
| // defined register may be used by other instructions; in such cases, | ||||||||
| // we need to extract the 32-bit register used by other | ||||||||
| // non-promoted 32-bit instructions from the promoted 64-bit register. | ||||||||
| void PPCInstrInfo::PromoteInstr32To64ForEmliEXTSW(const Register &Reg, | ||||||||
|
||||||||
| void PPCInstrInfo::PromoteInstr32To64ForEmliEXTSW(const Register &Reg, | |
| void PPCInstrInfo::PromoteInstr32To64ForElimEXTSW(const Register &Reg, |
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.
nit: remove empty line
lei137 marked this conversation as resolved.
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.
early exit
| 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.
This big switch stmt makes things a bit confusing. See comment above about replacing the lambda func CheckAndSetNewOpcode with a static helper function.
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.
Not needed since it doesn't do anything.
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.
early exit
| if (Operand.isReg()) { | |
| if (!Operand.isReg()) | |
| continue; |
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.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1050,7 +1050,16 @@ bool PPCMIPeephole::simplifyCode() { | |
| } else if (MI.getOpcode() == PPC::EXTSW_32_64 && | ||
| TII->isSignExtended(NarrowReg, MRI)) { | ||
| // We can eliminate EXTSW if the input is known to be already | ||
| // sign-extended. | ||
| // sign-extended. but we are not sure whether a spill will occur | ||
| // during register allocation. All these instructions in the chain | ||
| // used to deduce sign extension to eliminate the 'extsw' will need to | ||
| // be promoted to 64-bit pseudo instructions when the 'extsw' is | ||
| // eliminated. If there is no promotion, it will use the 'stw' instead | ||
| // of 'std', and 'lwz' instead of 'ld' when spilling, since the | ||
| // register class is 32-bits. Consequently, the high 32-bit | ||
| // information will be lost. | ||
|
||
| TII->PromoteInstr32To64ForEmliEXTSW(NarrowReg, MRI, 0, LV); | ||
|
|
||
| LLVM_DEBUG(dbgs() << "Removing redundant sign-extension\n"); | ||
| Register TmpReg = | ||
| MF->getRegInfo().createVirtualRegister(&PPC::G8RCRegClass); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.