@@ -519,36 +519,6 @@ static bool isRegInClass(const MachineOperand &MO,
519
519
}
520
520
521
521
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
-
552
522
// We want to find out if the tail-predicated version of this loop will
553
523
// produce the same values as the loop in its original form. For this to
554
524
// be true, the newly inserted implicit predication must not change the
@@ -570,8 +540,10 @@ bool LowOverheadLoop::ValidateLiveOuts() const {
570
540
// loop and the tail-predicated form too. Because of this, we can insert
571
541
// loads, stores and other predicated instructions into our KnownFalseZeros
572
542
// set and build from there.
543
+ const TargetRegisterClass *QPRs = TRI.getRegClass (ARM::MQPRRegClassID);
573
544
SetVector<MachineInstr *> UnknownFalseLanes;
574
545
SmallPtrSet<MachineInstr *, 4 > KnownFalseZeros;
546
+ MachineBasicBlock *MBB = ML.getHeader ();
575
547
for (auto &MI : *MBB) {
576
548
const MCInstrDesc &MCID = MI.getDesc ();
577
549
uint64_t Flags = MCID.TSFlags ;
@@ -637,6 +609,35 @@ bool LowOverheadLoop::ValidateLiveOuts() const {
637
609
// Any unknown false lanes have been masked away by the user(s).
638
610
KnownFalseZeros.insert (MI);
639
611
}
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
+
640
641
return true ;
641
642
}
642
643
0 commit comments