Skip to content

Commit d9d4ba6

Browse files
committed
[AMDGPU] Reduce use of continue in SIWholeQuadMode. NFC.
1 parent 4ad2f41 commit d9d4ba6

File tree

1 file changed

+36
-56
lines changed

1 file changed

+36
-56
lines changed

llvm/lib/Target/AMDGPU/SIWholeQuadMode.cpp

Lines changed: 36 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -278,11 +278,10 @@ LLVM_DUMP_METHOD void SIWholeQuadMode::printInfo() {
278278

279279
for (const MachineInstr &MI : *BII.first) {
280280
auto III = Instructions.find(&MI);
281-
if (III == Instructions.end())
282-
continue;
283-
284-
dbgs() << " " << MI << " Needs = " << PrintState(III->second.Needs)
285-
<< ", OutNeeds = " << PrintState(III->second.OutNeeds) << '\n';
281+
if (III != Instructions.end()) {
282+
dbgs() << " " << MI << " Needs = " << PrintState(III->second.Needs)
283+
<< ", OutNeeds = " << PrintState(III->second.OutNeeds) << '\n';
284+
}
286285
}
287286
}
288287
}
@@ -455,10 +454,8 @@ void SIWholeQuadMode::markOperand(const MachineInstr &MI,
455454
for (MCRegUnit Unit : TRI->regunits(Reg.asMCReg())) {
456455
LiveRange &LR = LIS->getRegUnit(Unit);
457456
const VNInfo *Value = LR.Query(LIS->getInstructionIndex(MI)).valueIn();
458-
if (!Value)
459-
continue;
460-
461-
markDefs(MI, LR, Unit, AMDGPU::NoSubRegister, Flag, Worklist);
457+
if (Value)
458+
markDefs(MI, LR, Unit, AMDGPU::NoSubRegister, Flag, Worklist);
462459
}
463460
}
464461
}
@@ -499,19 +496,16 @@ char SIWholeQuadMode::scanInstructions(MachineFunction &MF,
499496

500497
if (TII->isWQM(Opcode)) {
501498
// If LOD is not supported WQM is not needed.
502-
if (!ST->hasExtendedImageInsts())
503-
continue;
504499
// Only generate implicit WQM if implicit derivatives are required.
505500
// This avoids inserting unintended WQM if a shader type without
506501
// implicit derivatives uses an image sampling instruction.
507-
if (!HasImplicitDerivatives)
508-
continue;
509-
// Sampling instructions don't need to produce results for all pixels
510-
// in a quad, they just require all inputs of a quad to have been
511-
// computed for derivatives.
512-
markInstructionUses(MI, StateWQM, Worklist);
513-
GlobalFlags |= StateWQM;
514-
continue;
502+
if (ST->hasExtendedImageInsts() && HasImplicitDerivatives) {
503+
// Sampling instructions don't need to produce results for all pixels
504+
// in a quad, they just require all inputs of a quad to have been
505+
// computed for derivatives.
506+
markInstructionUses(MI, StateWQM, Worklist);
507+
GlobalFlags |= StateWQM;
508+
}
515509
} else if (Opcode == AMDGPU::WQM) {
516510
// The WQM intrinsic requires its output to have all the helper lanes
517511
// correct, so we need it to be in WQM.
@@ -520,15 +514,13 @@ char SIWholeQuadMode::scanInstructions(MachineFunction &MF,
520514
} else if (Opcode == AMDGPU::SOFT_WQM) {
521515
LowerToCopyInstrs.push_back(&MI);
522516
SoftWQMInstrs.push_back(&MI);
523-
continue;
524517
} else if (Opcode == AMDGPU::STRICT_WWM) {
525518
// The STRICT_WWM intrinsic doesn't make the same guarantee, and plus
526519
// it needs to be executed in WQM or Exact so that its copy doesn't
527520
// clobber inactive lanes.
528521
markInstructionUses(MI, StateStrictWWM, Worklist);
529522
GlobalFlags |= StateStrictWWM;
530523
LowerToMovInstrs.push_back(&MI);
531-
continue;
532524
} else if (Opcode == AMDGPU::STRICT_WQM ||
533525
TII->isDualSourceBlendEXP(MI)) {
534526
// STRICT_WQM is similar to STRICTWWM, but instead of enabling all
@@ -551,7 +543,6 @@ char SIWholeQuadMode::scanInstructions(MachineFunction &MF,
551543
GlobalFlags |= StateExact;
552544
III.Disabled = StateWQM | StateStrict;
553545
}
554-
continue;
555546
} else if (Opcode == AMDGPU::LDS_PARAM_LOAD ||
556547
Opcode == AMDGPU::DS_PARAM_LOAD ||
557548
Opcode == AMDGPU::LDS_DIRECT_LOAD ||
@@ -561,7 +552,6 @@ char SIWholeQuadMode::scanInstructions(MachineFunction &MF,
561552
InstrInfo &II = Instructions[&MI];
562553
II.Needs |= StateStrictWQM;
563554
GlobalFlags |= StateStrictWQM;
564-
continue;
565555
} else if (Opcode == AMDGPU::V_SET_INACTIVE_B32 ||
566556
Opcode == AMDGPU::V_SET_INACTIVE_B64) {
567557
III.Disabled = StateStrict;
@@ -574,7 +564,6 @@ char SIWholeQuadMode::scanInstructions(MachineFunction &MF,
574564
}
575565
}
576566
SetInactiveInstrs.push_back(&MI);
577-
continue;
578567
} else if (TII->isDisableWQM(MI)) {
579568
BBI.Needs |= StateExact;
580569
if (!(BBI.InNeeds & StateExact)) {
@@ -583,40 +572,33 @@ char SIWholeQuadMode::scanInstructions(MachineFunction &MF,
583572
}
584573
GlobalFlags |= StateExact;
585574
III.Disabled = StateWQM | StateStrict;
586-
continue;
587-
} else {
588-
if (Opcode == AMDGPU::SI_PS_LIVE || Opcode == AMDGPU::SI_LIVE_MASK) {
589-
LiveMaskQueries.push_back(&MI);
590-
} else if (Opcode == AMDGPU::SI_KILL_I1_TERMINATOR ||
591-
Opcode == AMDGPU::SI_KILL_F32_COND_IMM_TERMINATOR ||
592-
Opcode == AMDGPU::SI_DEMOTE_I1) {
593-
KillInstrs.push_back(&MI);
594-
BBI.NeedsLowering = true;
595-
} else if (WQMOutputs) {
596-
// The function is in machine SSA form, which means that physical
597-
// VGPRs correspond to shader inputs and outputs. Inputs are
598-
// only used, outputs are only defined.
599-
// FIXME: is this still valid?
600-
for (const MachineOperand &MO : MI.defs()) {
601-
if (!MO.isReg())
602-
continue;
603-
604-
Register Reg = MO.getReg();
605-
606-
if (!Reg.isVirtual() &&
607-
TRI->hasVectorRegisters(TRI->getPhysRegBaseClass(Reg))) {
608-
Flags = StateWQM;
609-
break;
610-
}
575+
} else if (Opcode == AMDGPU::SI_PS_LIVE ||
576+
Opcode == AMDGPU::SI_LIVE_MASK) {
577+
LiveMaskQueries.push_back(&MI);
578+
} else if (Opcode == AMDGPU::SI_KILL_I1_TERMINATOR ||
579+
Opcode == AMDGPU::SI_KILL_F32_COND_IMM_TERMINATOR ||
580+
Opcode == AMDGPU::SI_DEMOTE_I1) {
581+
KillInstrs.push_back(&MI);
582+
BBI.NeedsLowering = true;
583+
} else if (WQMOutputs) {
584+
// The function is in machine SSA form, which means that physical
585+
// VGPRs correspond to shader inputs and outputs. Inputs are
586+
// only used, outputs are only defined.
587+
// FIXME: is this still valid?
588+
for (const MachineOperand &MO : MI.defs()) {
589+
Register Reg = MO.getReg();
590+
if (Reg.isPhysical() &&
591+
TRI->hasVectorRegisters(TRI->getPhysRegBaseClass(Reg))) {
592+
Flags = StateWQM;
593+
break;
611594
}
612595
}
613-
614-
if (!Flags)
615-
continue;
616596
}
617597

618-
markInstruction(MI, Flags, Worklist);
619-
GlobalFlags |= Flags;
598+
if (Flags) {
599+
markInstruction(MI, Flags, Worklist);
600+
GlobalFlags |= Flags;
601+
}
620602
}
621603
}
622604

@@ -1568,8 +1550,6 @@ void SIWholeQuadMode::lowerKillInstrs(bool IsWQM) {
15681550
case AMDGPU::SI_KILL_F32_COND_IMM_TERMINATOR:
15691551
SplitPoint = lowerKillF32(*MBB, *MI);
15701552
break;
1571-
default:
1572-
continue;
15731553
}
15741554
if (SplitPoint)
15751555
splitBlock(MBB, SplitPoint);

0 commit comments

Comments
 (0)