Skip to content

Commit d941df3

Browse files
committed
[NFC][ARM] Reorder some logic
Move some logic around in LowOverheadLoop::ValidateLiveOut
1 parent b3b4727 commit d941df3

File tree

1 file changed

+31
-30
lines changed

1 file changed

+31
-30
lines changed

llvm/lib/Target/ARM/ARMLowOverheadLoops.cpp

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -519,36 +519,6 @@ static bool isRegInClass(const MachineOperand &MO,
519519
}
520520

521521
bool LowOverheadLoop::ValidateLiveOuts() const {
522-
// Collect Q-regs that are live in the exit blocks. We don't collect scalars
523-
// because they won't be affected by lane predication.
524-
const TargetRegisterClass *QPRs = TRI.getRegClass(ARM::MQPRRegClassID);
525-
SmallSet<Register, 2> LiveOuts;
526-
SmallVector<MachineBasicBlock *, 2> ExitBlocks;
527-
ML.getExitBlocks(ExitBlocks);
528-
for (auto *MBB : ExitBlocks)
529-
for (const MachineBasicBlock::RegisterMaskPair &RegMask : MBB->liveins())
530-
if (QPRs->contains(RegMask.PhysReg))
531-
LiveOuts.insert(RegMask.PhysReg);
532-
533-
// Collect the instructions in the loop body that define the live-out values.
534-
SmallPtrSet<MachineInstr *, 2> LiveMIs;
535-
assert(ML.getNumBlocks() == 1 && "Expected single block loop!");
536-
MachineBasicBlock *MBB = ML.getHeader();
537-
for (auto Reg : LiveOuts)
538-
if (auto *MI = RDA.getLocalLiveOutMIDef(MBB, Reg))
539-
LiveMIs.insert(MI);
540-
541-
LLVM_DEBUG(dbgs() << "ARM Loops: Found loop live-outs:\n";
542-
for (auto *MI : LiveMIs)
543-
dbgs() << " - " << *MI);
544-
// We've already validated that any VPT predication within the loop will be
545-
// equivalent when we perform the predication transformation; so we know that
546-
// any VPT predicated instruction is predicated upon VCTP. Any live-out
547-
// instruction needs to be predicated, so check this here.
548-
for (auto *MI : LiveMIs)
549-
if (!isVectorPredicated(MI))
550-
return false;
551-
552522
// We want to find out if the tail-predicated version of this loop will
553523
// produce the same values as the loop in its original form. For this to
554524
// be true, the newly inserted implicit predication must not change the
@@ -570,8 +540,10 @@ bool LowOverheadLoop::ValidateLiveOuts() const {
570540
// loop and the tail-predicated form too. Because of this, we can insert
571541
// loads, stores and other predicated instructions into our KnownFalseZeros
572542
// set and build from there.
543+
const TargetRegisterClass *QPRs = TRI.getRegClass(ARM::MQPRRegClassID);
573544
SetVector<MachineInstr *> UnknownFalseLanes;
574545
SmallPtrSet<MachineInstr *, 4> KnownFalseZeros;
546+
MachineBasicBlock *MBB = ML.getHeader();
575547
for (auto &MI : *MBB) {
576548
const MCInstrDesc &MCID = MI.getDesc();
577549
uint64_t Flags = MCID.TSFlags;
@@ -637,6 +609,35 @@ bool LowOverheadLoop::ValidateLiveOuts() const {
637609
// Any unknown false lanes have been masked away by the user(s).
638610
KnownFalseZeros.insert(MI);
639611
}
612+
613+
// Collect Q-regs that are live in the exit blocks. We don't collect scalars
614+
// because they won't be affected by lane predication.
615+
SmallSet<Register, 2> LiveOuts;
616+
SmallVector<MachineBasicBlock *, 2> ExitBlocks;
617+
ML.getExitBlocks(ExitBlocks);
618+
for (auto *MBB : ExitBlocks)
619+
for (const MachineBasicBlock::RegisterMaskPair &RegMask : MBB->liveins())
620+
if (QPRs->contains(RegMask.PhysReg))
621+
LiveOuts.insert(RegMask.PhysReg);
622+
623+
// Collect the instructions in the loop body that define the live-out values.
624+
SmallPtrSet<MachineInstr *, 2> LiveMIs;
625+
assert(ML.getNumBlocks() == 1 && "Expected single block loop!");
626+
for (auto Reg : LiveOuts)
627+
if (auto *MI = RDA.getLocalLiveOutMIDef(MBB, Reg))
628+
LiveMIs.insert(MI);
629+
630+
LLVM_DEBUG(dbgs() << "ARM Loops: Found loop live-outs:\n";
631+
for (auto *MI : LiveMIs)
632+
dbgs() << " - " << *MI);
633+
// We've already validated that any VPT predication within the loop will be
634+
// equivalent when we perform the predication transformation; so we know that
635+
// any VPT predicated instruction is predicated upon VCTP. Any live-out
636+
// instruction needs to be predicated, so check this here.
637+
for (auto *MI : LiveMIs)
638+
if (!isVectorPredicated(MI))
639+
return false;
640+
640641
return true;
641642
}
642643

0 commit comments

Comments
 (0)