X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FCodeGen%2FSelectionDAG%2FScheduleDAGRRList.cpp;h=6ea7c80687820ec878251f7c200c7edaaed91816;hb=4ee451de366474b9c228b4e5fa573795a715216d;hp=3b2679dd20f04575f4bc54fb22fa07badb5dfd75;hpb=d6c0758944b31bb5316b36cad37f4610a77f784d;p=oota-llvm.git diff --git a/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp b/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp index 3b2679dd20f..6ea7c806878 100644 --- a/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp +++ b/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp @@ -2,8 +2,8 @@ // // The LLVM Compiler Infrastructure // -// This file was developed by Evan Cheng and is distributed under the -// University of Illinois Open Source License. See LICENSE.TXT for details. +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // @@ -1064,9 +1064,11 @@ namespace { std::vector SethiUllmanNumbers; const TargetInstrInfo *TII; + const MRegisterInfo *MRI; public: - explicit BURegReductionPriorityQueue(const TargetInstrInfo *tii) - : TII(tii) {} + explicit BURegReductionPriorityQueue(const TargetInstrInfo *tii, + const MRegisterInfo *mri) + : TII(tii), MRI(mri) {} void initNodes(DenseMap > &sumap, std::vector &sunits) { @@ -1314,6 +1316,33 @@ static bool hasCopyToRegUse(SUnit *SU) { return false; } +/// canClobberPhysRegDefs - True if SU would clobber one of SuccSU's +/// physical register def. +static bool canClobberPhysRegDefs(SUnit *SuccSU, SUnit *SU, + const TargetInstrInfo *TII, + const MRegisterInfo *MRI) { + SDNode *N = SuccSU->Node; + unsigned NumDefs = TII->getNumDefs(N->getTargetOpcode()); + const unsigned *ImpDefs = TII->getImplicitDefs(N->getTargetOpcode()); + if (!ImpDefs) + return false; + const unsigned *SUImpDefs = TII->getImplicitDefs(SU->Node->getTargetOpcode()); + if (!SUImpDefs) + return false; + for (unsigned i = NumDefs, e = N->getNumValues(); i != e; ++i) { + MVT::ValueType VT = N->getValueType(i); + if (VT == MVT::Flag || VT == MVT::Other) + continue; + unsigned Reg = ImpDefs[i - NumDefs]; + for (;*SUImpDefs; ++SUImpDefs) { + unsigned SUReg = *SUImpDefs; + if (MRI->regsOverlap(Reg, SUReg)) + return true; + } + } + return false; +} + /// AddPseudoTwoAddrDeps - If two nodes share an operand and one of them uses /// it as a def&use operand. Add a pseudo control edge from it to the other /// node (if it won't create a cycle) so the two-address one will be scheduled @@ -1346,18 +1375,20 @@ void BURegReductionPriorityQueue::AddPseudoTwoAddrDeps() { I != E; ++I) { if (I->isCtrl) continue; SUnit *SuccSU = I->Dep; - // Don't constrain nodes with implicit defs. It can create cycles - // plus it may increase register pressures. - if (SuccSU == SU || SuccSU->hasPhysRegDefs) + if (SuccSU == SU) continue; // Be conservative. Ignore if nodes aren't at roughly the same // depth and height. if (SuccSU->Height < SU->Height && (SU->Height - SuccSU->Height) > 1) continue; - if (SuccSU->Depth > SU->Depth && (SuccSU->Depth - SU->Depth) > 1) - continue; if (!SuccSU->Node || !SuccSU->Node->isTargetOpcode()) continue; + // Don't constrain nodes with physical register defs if the + // predecessor can cloober them. + if (SuccSU->hasPhysRegDefs) { + if (canClobberPhysRegDefs(SuccSU, SU, TII, MRI)) + continue; + } // Don't constraint extract_subreg / insert_subreg these may be // coalesced away. We don't them close to their uses. unsigned SuccOpc = SuccSU->Node->getTargetOpcode(); @@ -1547,8 +1578,9 @@ llvm::ScheduleDAG* llvm::createBURRListDAGScheduler(SelectionDAGISel *IS, SelectionDAG *DAG, MachineBasicBlock *BB) { const TargetInstrInfo *TII = DAG->getTarget().getInstrInfo(); + const MRegisterInfo *MRI = DAG->getTarget().getRegisterInfo(); return new ScheduleDAGRRList(*DAG, BB, DAG->getTarget(), true, - new BURegReductionPriorityQueue(TII)); + new BURegReductionPriorityQueue(TII, MRI)); } llvm::ScheduleDAG* llvm::createTDRRListDAGScheduler(SelectionDAGISel *IS,