@@ -716,6 +716,31 @@ unsigned GCNSubtarget::getMaxNumVGPRs(const MachineFunction &MF) const {
716
716
return MaxNumVGPRs;
717
717
}
718
718
719
+ void GCNSubtarget::adjustSchedDependency (SUnit *Src, SUnit *Dst,
720
+ SDep &Dep) const {
721
+ if (Dep.getKind () != SDep::Kind::Data || !Dep.getReg () ||
722
+ !Src->isInstr () || !Dst->isInstr ())
723
+ return ;
724
+
725
+ MachineInstr *SrcI = Src->getInstr ();
726
+ MachineInstr *DstI = Dst->getInstr ();
727
+
728
+ if (SrcI->isBundle ()) {
729
+ const SIRegisterInfo *TRI = getRegisterInfo ();
730
+ auto Reg = Dep.getReg ();
731
+ MachineBasicBlock::const_instr_iterator I (SrcI->getIterator ());
732
+ MachineBasicBlock::const_instr_iterator E (SrcI->getParent ()->instr_end ());
733
+ for (++I; I != E && I->isBundledWithPred (); ++I) {
734
+ if (!I->modifiesRegister (Reg, TRI))
735
+ continue ;
736
+ Dep.setLatency (InstrInfo.getInstrLatency (getInstrItineraryData (), *I));
737
+ break ;
738
+ }
739
+ } else if (DstI->isBundle ()) {
740
+ Dep.setLatency (InstrInfo.getInstrLatency (getInstrItineraryData (), *SrcI));
741
+ }
742
+ }
743
+
719
744
namespace {
720
745
struct MemOpClusterMutation : ScheduleDAGMutation {
721
746
const SIInstrInfo *TII;
@@ -764,45 +789,6 @@ struct MemOpClusterMutation : ScheduleDAGMutation {
764
789
}
765
790
};
766
791
767
- struct FixBundleLatencyMutation : ScheduleDAGMutation {
768
- const SIInstrInfo *TII;
769
-
770
- const TargetSchedModel *TSchedModel;
771
-
772
- FixBundleLatencyMutation (const SIInstrInfo *tii) : TII(tii) {}
773
-
774
- unsigned computeLatency (const MachineInstr &MI, unsigned Reg) const {
775
- const SIRegisterInfo &TRI = TII->getRegisterInfo ();
776
- MachineBasicBlock::const_instr_iterator I (MI.getIterator ());
777
- MachineBasicBlock::const_instr_iterator E (MI.getParent ()->instr_end ());
778
- unsigned Lat = 0 ;
779
- for (++I; I != E && I->isBundledWithPred (); ++I) {
780
- if (!I->modifiesRegister (Reg, &TRI))
781
- continue ;
782
- Lat = TSchedModel->computeInstrLatency (&*I);
783
- break ;
784
- }
785
- return Lat;
786
- }
787
-
788
- void apply (ScheduleDAGInstrs *DAGInstrs) override {
789
- ScheduleDAGMI *DAG = static_cast <ScheduleDAGMI*>(DAGInstrs);
790
- TSchedModel = DAGInstrs->getSchedModel ();
791
- if (!TSchedModel || DAG->SUnits .empty ())
792
- return ;
793
-
794
- for (SUnit &SU : DAG->SUnits ) {
795
- if (!SU.isInstr () || !SU.getInstr ()->isBundle ())
796
- continue ;
797
- for (SDep &Dep : SU.Succs ) {
798
- if (Dep.getKind () == SDep::Kind::Data && Dep.getReg ())
799
- if (unsigned Lat = computeLatency (*SU.getInstr (), Dep.getReg ()))
800
- Dep.setLatency (Lat);
801
- }
802
- }
803
- }
804
- };
805
-
806
792
struct FillMFMAShadowMutation : ScheduleDAGMutation {
807
793
const SIInstrInfo *TII;
808
794
@@ -929,7 +915,6 @@ struct FillMFMAShadowMutation : ScheduleDAGMutation {
929
915
930
916
void GCNSubtarget::getPostRAMutations (
931
917
std::vector<std::unique_ptr<ScheduleDAGMutation>> &Mutations) const {
932
- Mutations.push_back (std::make_unique<FixBundleLatencyMutation>(&InstrInfo));
933
918
Mutations.push_back (std::make_unique<MemOpClusterMutation>(&InstrInfo));
934
919
Mutations.push_back (std::make_unique<FillMFMAShadowMutation>(&InstrInfo));
935
920
}
0 commit comments