Deleted Added
sdiff udiff text old ( 263508 ) new ( 266715 )
full compact
1//===-- SILowerControlFlow.cpp - Use predicates for control flow ----------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//

--- 95 unchanged lines hidden (view full) ---

104} // End anonymous namespace
105
106char SILowerControlFlowPass::ID = 0;
107
108FunctionPass *llvm::createSILowerControlFlowPass(TargetMachine &tm) {
109 return new SILowerControlFlowPass(tm);
110}
111
112bool SILowerControlFlowPass::shouldSkip(MachineBasicBlock *From,
113 MachineBasicBlock *To) {
114
115 unsigned NumInstr = 0;
116
117 for (MachineBasicBlock *MBB = From; MBB != To && !MBB->succ_empty();
118 MBB = *MBB->succ_begin()) {
119

--- 20 unchanged lines hidden (view full) ---

140 .addReg(AMDGPU::EXEC);
141}
142
143void SILowerControlFlowPass::SkipIfDead(MachineInstr &MI) {
144
145 MachineBasicBlock &MBB = *MI.getParent();
146 DebugLoc DL = MI.getDebugLoc();
147
148 if (!shouldSkip(&MBB, &MBB.getParent()->back()))
149 return;
150
151 MachineBasicBlock::iterator Insert = &MI;
152 ++Insert;
153
154 // If the exec mask is non-zero, skip the next two instructions
155 BuildMI(MBB, Insert, DL, TII->get(AMDGPU::S_CBRANCH_EXECNZ))
156 .addImm(3)

--- 134 unchanged lines hidden (view full) ---

291 assert(0);
292}
293
294void SILowerControlFlowPass::Kill(MachineInstr &MI) {
295
296 MachineBasicBlock &MBB = *MI.getParent();
297 DebugLoc DL = MI.getDebugLoc();
298
299 // Kill is only allowed in pixel shaders
300 assert(MBB.getParent()->getInfo<SIMachineFunctionInfo>()->ShaderType ==
301 ShaderType::PIXEL);
302
303 // Clear this pixel from the exec mask if the operand is negative
304 BuildMI(MBB, &MI, DL, TII->get(AMDGPU::V_CMPX_LE_F32_e32), AMDGPU::VCC)
305 .addImm(0)
306 .addOperand(MI.getOperand(0));
307
308 MI.eraseFromParent();
309}

--- 116 unchanged lines hidden (view full) ---

426 BI != BE; ++BI) {
427
428 MachineBasicBlock &MBB = *BI;
429 for (MachineBasicBlock::iterator I = MBB.begin(), Next = llvm::next(I);
430 I != MBB.end(); I = Next) {
431
432 Next = llvm::next(I);
433 MachineInstr &MI = *I;
434 switch (MI.getOpcode()) {
435 default: break;
436 case AMDGPU::SI_IF:
437 ++Depth;
438 If(MI);
439 break;
440
441 case AMDGPU::SI_ELSE:

--- 44 unchanged lines hidden (view full) ---

486 case AMDGPU::SI_INDIRECT_DST_V1:
487 case AMDGPU::SI_INDIRECT_DST_V2:
488 case AMDGPU::SI_INDIRECT_DST_V4:
489 case AMDGPU::SI_INDIRECT_DST_V8:
490 case AMDGPU::SI_INDIRECT_DST_V16:
491 IndirectDst(MI);
492 break;
493
494 case AMDGPU::DS_READ_B32:
495 NeedWQM = true;
496 // Fall through
497 case AMDGPU::DS_WRITE_B32:
498 case AMDGPU::DS_ADD_U32_RTN:
499 NeedM0 = true;
500 break;
501
502 case AMDGPU::V_INTERP_P1_F32:
503 case AMDGPU::V_INTERP_P2_F32:
504 case AMDGPU::V_INTERP_MOV_F32:
505 NeedWQM = true;
506 break;
507
508 }
509 }
510 }
511
512 if (NeedM0) {
513 MachineBasicBlock &MBB = MF.front();
514 // Initialize M0 to a value that won't cause LDS access to be discarded
515 // due to offset clamping
516 BuildMI(MBB, MBB.getFirstNonPHI(), DebugLoc(), TII->get(AMDGPU::S_MOV_B32),
517 AMDGPU::M0).addImm(0xffffffff);
518 }
519
520 if (NeedWQM && MFI->ShaderType != ShaderType::COMPUTE) {
521 MachineBasicBlock &MBB = MF.front();
522 BuildMI(MBB, MBB.getFirstNonPHI(), DebugLoc(), TII->get(AMDGPU::S_WQM_B64),
523 AMDGPU::EXEC).addReg(AMDGPU::EXEC);
524 }
525
526 return true;
527}