-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[RISCV][MacroFusion] Improve fusion in pre-RA #82738
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
Comments
@llvm/issue-subscribers-backend-risc-v Author: None (zxc12523)
#79425 has adopted TableGen-based macro fusion.
And it will generate RISCVGenMacroFusion.inc. bool isTuneAUIPCADDIFusion(
const TargetInstrInfo &TII,
const TargetSubtargetInfo &STI,
const MachineInstr *FirstMI,
const MachineInstr &SecondMI) {
auto &MRI = SecondMI.getMF()->getRegInfo();
{
const MachineInstr *MI = &SecondMI;
if (( MI->getOpcode() != RISCV::ADDI ))
return false;
}
if (!FirstMI)
return true;
{
const MachineInstr *MI = FirstMI;
if (( MI->getOpcode() != RISCV::AUIPC ))
return false;
}
{
const MachineInstr *MI = &SecondMI;
if (!(
MI->getOperand(0).getReg().isVirtual()
|| MI->getOperand(0).getReg() == MI->getOperand(1).getReg()
))
return false;
}
{
Register FirstDest = FirstMI->getOperand(0).getReg();
if (FirstDest.isVirtual() && !MRI.hasOneNonDBGUse(FirstDest))
return false;
}
if (!(FirstMI->getOperand(0).isReg() &&
SecondMI.getOperand(1).isReg() &&
FirstMI->getOperand(0).getReg() == SecondMI.getOperand(1).getReg()))
return false;
return true;
} My question is, is it possible to check |
Yes, it can be set via adding a This can be done automatically, I will create a PR for this. Thanks for reporting! |
If the second instruction is commutable, we should be able to check its commutable operands. A simple RISCV fusion is contained in this PR to show the functionality is correct, I may remove it when landing. There are some other issues I should fix. For example, we should be able to check that the destination register is tha same as the commutable operands. But I post this PR here firstly to gather feedbacks. Fixes llvm#82738
Thanks for your response! Are there any tablegen learning materials or source code reading tools I can use? I am a newbie and I want to learn more about this topic. |
You mean the TableGen-based macro fusion? I have some links that you can refer to:
Some code links:
|
If the second instruction is commutable, we should be able to check its commutable operands. A simple RISCV fusion is contained in this PR to show the functionality is correct, I may remove it when landing. There are some other issues I should fix. For example, we should be able to check that the destination register is tha same as the commutable operands. But I post this PR here firstly to gather feedbacks. Fixes llvm#82738
If the second instruction is commutable, we should be able to check its commutable operands. A simple RISCV fusion is contained in this PR to show the functionality is correct, I may remove it when landing. Fixes llvm#82738
If the second instruction is commutable, we should be able to check its commutable operands. A field `IsCommutable` is added to indicate whether we should generate code for checking commutable operands. A simple RISCV fusion is contained in this PR to show the functionality is correct, I may remove it when landing. Fixes llvm#82738
If the second instruction is commutable, we should be able to check its commutable operands. A field `IsCommutable` is added to indicate whether we should generate code for checking commutable operands. Fixes llvm#82738
If the second instruction is commutable, we should be able to check its commutable operands. A simple RISCV fusion is contained in this PR to show the functionality is correct, I may remove it when landing. Fixes #82738
#79425 has adopted TableGen-based macro fusion.
And it will generate RISCVGenMacroFusion.inc.
My question is, is it possible to check
FirstMI->getOperand(0).getReg() == SecondMI.getOperand(2).getReg()
when these two regs are virtual and the second inst is commutative?The text was updated successfully, but these errors were encountered: