File tree Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -231,8 +231,8 @@ static inline void hoistUnrelatedCopies(MachineFunction &MF) {
231231 while (!CopyMoveIt.isEnd ()) {
232232 EpilogIterator Next = CopyMoveIt;
233233 ++Next;
234- if (CopyMoveIt->getOpcode () == AMDGPU::COPY &&
235- !RelatedCopySources.count (CopyMoveIt->getOperand (1 ).getReg ()) ||
234+ if (( CopyMoveIt->getOpcode () == AMDGPU::COPY &&
235+ !RelatedCopySources.count (CopyMoveIt->getOperand (1 ).getReg () )) ||
236236 CopyMoveIt->getOpcode () == AMDGPU::IMPLICIT_DEF) {
237237 MachineInstr &MIToMove = *CopyMoveIt;
238238 MIToMove.removeFromBundle ();
@@ -243,3 +243,19 @@ static inline void hoistUnrelatedCopies(MachineFunction &MF) {
243243 }
244244 }
245245}
246+
247+ static inline bool makeEverySuccessorBeBranchTarget (MachineFunction &MF) {
248+ bool Changed = false ;
249+ auto &TII = *MF.getSubtarget <GCNSubtarget>().getInstrInfo ();
250+ for (MachineBasicBlock &MBB : MF)
251+ if (MBB.empty () ||
252+ (!MBB.back ().isUnconditionalBranch () && !MBB.back ().isReturn ())) {
253+ MachineBasicBlock *LayoutSuccessor =
254+ &*std::next (MachineFunction::iterator (MBB));
255+ BuildMI (&MBB, DebugLoc (), TII.get (AMDGPU::S_BRANCH))
256+ .addMBB (LayoutSuccessor);
257+ Changed = true ;
258+ }
259+
260+ return Changed;
261+ }
Original file line number Diff line number Diff line change @@ -800,7 +800,7 @@ bool SILowerControlFlow::run(MachineFunction &MF) {
800800 }
801801 }
802802
803- bool Changed = false ;
803+ bool Changed = makeEverySuccessorBeBranchTarget (MF) ;
804804 MachineFunction::iterator NextBB;
805805 for (MachineFunction::iterator BI = MF.begin ();
806806 BI != MF.end (); BI = NextBB) {
You can’t perform that action at this time.
0 commit comments