MachineInstr *getLoopendBlockBranchInstr(MachineBasicBlock *MBB);
static MachineInstr *getReturnInstr(MachineBasicBlock *MBB);
static MachineInstr *getContinueInstr(MachineBasicBlock *MBB);
- static MachineInstr *getLoopBreakInstr(MachineBasicBlock *MBB);
static bool isReturnBlock(MachineBasicBlock *MBB);
static void cloneSuccessorList(MachineBasicBlock *DstMBB,
MachineBasicBlock *SrcMBB) ;
return NULL;
}
-MachineInstr *AMDGPUCFGStructurizer::getLoopBreakInstr(MachineBasicBlock *MBB) {
- for (MachineBasicBlock::iterator It = MBB->begin(); (It != MBB->end());
- ++It) {
- MachineInstr *MI = &(*It);
- if (MI->getOpcode() == AMDGPU::PREDICATED_BREAK)
- return MI;
- }
- return NULL;
-}
-
bool AMDGPUCFGStructurizer::isReturnBlock(MachineBasicBlock *MBB) {
MachineInstr *MI = getReturnInstr(MBB);
bool IsReturn = (MBB->succ_size() == 0);
DEBUG(dbgs() << "loopPattern header = BB" << DstBlk->getNumber()
<< " land = BB" << LandMBB->getNumber() << "\n";);
- /* we last inserterd the DebugLoc in the
- * BREAK_LOGICALZ_i32 or AMDGPU::BREAK_LOGICALNZ statement in the current
- * dstBlk.
- * search for the DebugLoc in the that statement.
- * if not found, we have to insert the empty/default DebugLoc */
- MachineInstr *LoopBreakInstr = getLoopBreakInstr(DstBlk);
- DebugLoc DLBreak = (LoopBreakInstr) ? LoopBreakInstr->getDebugLoc() :
- DebugLoc();
-
- insertInstrBefore(DstBlk, AMDGPU::WHILELOOP, DLBreak);
-
- /* we last inserterd the DebugLoc in the continue statement in the current
- * dstBlk.
- * search for the DebugLoc in the continue statement.
- * if not found, we have to insert the empty/default DebugLoc */
- MachineInstr *ContinueInstr = getContinueInstr(DstBlk);
- DebugLoc DLContinue = (ContinueInstr) ? ContinueInstr->getDebugLoc() :
- DebugLoc();
-
- insertInstrEnd(DstBlk, AMDGPU::ENDLOOP, DLContinue);
+ insertInstrBefore(DstBlk, AMDGPU::WHILELOOP, DebugLoc());
+ insertInstrEnd(DstBlk, AMDGPU::ENDLOOP, DebugLoc());
DstBlk->addSuccessor(LandMBB);
DstBlk->removeSuccessor(DstBlk);
}
MachineBasicBlock::iterator I = BranchMI;
if (TrueBranch != LandMBB)
reversePredicateSetter(I);
- insertCondBranchBefore(I, AMDGPU::PREDICATED_BREAK, DL);
+ insertCondBranchBefore(ExitingMBB, I, AMDGPU::IF_PREDICATE_SET, AMDGPU::PREDICATE_BIT, DL);
+ insertInstrBefore(I, AMDGPU::BREAK);
+ insertInstrBefore(I, AMDGPU::ENDIF);
//now branchInst can be erase safely
BranchMI->eraseFromParent();
//now take care of successors, retire blocks
MI.eraseFromParent();
continue;
}
- case AMDGPU::BREAK: {
- MachineInstr *PredSet = TII->buildDefaultInstruction(MBB, I,
- AMDGPU::PRED_SETE_INT,
- AMDGPU::PREDICATE_BIT,
- AMDGPU::ZERO,
- AMDGPU::ZERO);
- TII->addFlag(PredSet, 0, MO_FLAG_MASK);
- TII->setImmOperand(PredSet, AMDGPU::OpName::update_exec_mask, 1);
-
- BuildMI(MBB, I, MBB.findDebugLoc(I),
- TII->get(AMDGPU::PREDICATED_BREAK))
- .addReg(AMDGPU::PREDICATE_BIT);
- MI.eraseFromParent();
- continue;
- }
case AMDGPU::INTERP_PAIR_XY: {
MachineInstr *BMI;