[PATCH] D87107: [AMDGPU] Target hook to apply target specific split constraint
Alexander via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 4 10:22:13 PDT 2020
alex-t updated this revision to Diff 289990.
alex-t added a comment.
Now the correct diff uploaded
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D87107/new/
https://reviews.llvm.org/D87107
Files:
llvm/include/llvm/CodeGen/TargetInstrInfo.h
llvm/lib/CodeGen/RegAllocGreedy.cpp
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
llvm/lib/Target/AMDGPU/SIInstrInfo.h
Index: llvm/lib/Target/AMDGPU/SIInstrInfo.h
===================================================================
--- llvm/lib/Target/AMDGPU/SIInstrInfo.h
+++ llvm/lib/Target/AMDGPU/SIInstrInfo.h
@@ -981,6 +981,8 @@
bool isBasicBlockPrologue(const MachineInstr &MI) const override;
+ bool IsValidForLISplit(MachineBasicBlock *MBB) const override;
+
MachineInstr *createPHIDestinationCopy(MachineBasicBlock &MBB,
MachineBasicBlock::iterator InsPt,
const DebugLoc &DL, Register Src,
Index: llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
+++ llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
@@ -6803,6 +6803,45 @@
MI.modifiesRegister(AMDGPU::EXEC, &RI);
}
+bool SIInstrInfo::IsValidForLISplit(MachineBasicBlock *MBB) const {
+ MachineFunction *MF = MBB->getParent();
+ const TargetRegisterInfo *TRI = MF->getRegInfo().getTargetRegisterInfo();
+ auto IsExecRestore = [TRI](MachineInstr *Instr) {
+ return (Instr->modifiesRegister(AMDGPU::EXEC, TRI) &&
+ (Instr->getOpcode() == AMDGPU::S_OR_B64) ||
+ (Instr->getOpcode() == AMDGPU::S_MOV_B64 &&
+ Instr->getOperand(0).getReg() == AMDGPU::EXEC));
+ };
+ for (auto Pred : MBB->predecessors()) {
+ MachineBasicBlock::iterator I = Pred->getFirstTerminator();
+ if (I != Pred->end() && I->modifiesRegister(AMDGPU::EXEC, TRI)) {
+ while (++I != Pred->end()) {
+ if (I->getOpcode() == AMDGPU::S_CBRANCH_EXECNZ) {
+ if ((++I)->getOpcode() == AMDGPU::S_BRANCH &&
+ I->getOperand(0).getMBB() == MBB) {
+ break;
+ }
+ } else if (I->getOpcode() == AMDGPU::S_CBRANCH_EXECZ &&
+ I->getOperand(0).getMBB() == MBB) {
+ break;
+ }
+ }
+ if (I != Pred->end()) {
+ // One of the Preds passes control to MBB with EXEC == 0
+ // Let's look for EXEC restoring instructions
+ MachineBasicBlock::iterator J = MBB->begin();
+ while (isBasicBlockPrologue(*J)) {
+ if (IsExecRestore(&*J))
+ return true;
+ J++;
+ }
+ return false;
+ }
+ }
+ }
+ return true;
+}
+
MachineInstrBuilder
SIInstrInfo::getAddNoCarry(MachineBasicBlock &MBB,
MachineBasicBlock::iterator I,
Index: llvm/lib/CodeGen/RegAllocGreedy.cpp
===================================================================
--- llvm/lib/CodeGen/RegAllocGreedy.cpp
+++ llvm/lib/CodeGen/RegAllocGreedy.cpp
@@ -1259,7 +1259,8 @@
for (unsigned i = 0; i != Blocks.size(); ++i) {
unsigned Number = Blocks[i];
Intf.moveToBlock(Number);
-
+ if (!TII->IsValidForLISplit(MF->getBlockNumbered(Number)))
+ return false;
if (!Intf.hasInterference()) {
assert(T < GroupSize && "Array overflow");
TBS[T] = Number;
Index: llvm/include/llvm/CodeGen/TargetInstrInfo.h
===================================================================
--- llvm/include/llvm/CodeGen/TargetInstrInfo.h
+++ llvm/include/llvm/CodeGen/TargetInstrInfo.h
@@ -1749,6 +1749,8 @@
return false;
}
+ virtual bool IsValidForLISplit(MachineBasicBlock *MBB) const { return true; }
+
/// During PHI eleimination lets target to make necessary checks and
/// insert the copy to the PHI destination register in a target specific
/// manner.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87107.289990.patch
Type: text/x-patch
Size: 3485 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200904/1af6e7bd/attachment.bin>
More information about the llvm-commits
mailing list