[llvm-branch-commits] [llvm-branch] r324082 - Merging r323857:

Hans Wennborg via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Feb 2 05:35:26 PST 2018


Author: hans
Date: Fri Feb  2 05:35:26 2018
New Revision: 324082

URL: http://llvm.org/viewvc/llvm-project?rev=324082&view=rev
Log:
Merging r323857:
------------------------------------------------------------------------
r323857 | rogfer01 | 2018-01-31 10:23:43 +0100 (Wed, 31 Jan 2018) | 19 lines

[ARM] Allow the scheduler to clone a node with glue to avoid a copy CPSR ↔ GPR.

In Thumb 1, with the new ADDCARRY / SUBCARRY the scheduler may need to do
copies CPSR ↔ GPR but not all Thumb1 targets implement them.

The schedule can attempt, before attempting a copy, to clone the instructions
but it does not currently do that for nodes with input glue. In this patch we
introduce a target-hook to let the hook decide if a glued machinenode is still
eligible for copying. In this case these are ARM::tADCS and ARM::tSBCS .

As a follow-up of this change we should actually implement the copies for the
Thumb1 targets that do implement them and restrict the hook to the targets that
can't really do such copy as these clones are not ideal.

This change fixes PR35836.

Differential Revision: https://reviews.llvm.org/D42051


------------------------------------------------------------------------

Added:
    llvm/branches/release_60/test/CodeGen/Thumb/pr35836.ll
      - copied unchanged from r323857, llvm/trunk/test/CodeGen/Thumb/pr35836.ll
    llvm/branches/release_60/test/CodeGen/Thumb/pr35836_2.ll
      - copied unchanged from r323857, llvm/trunk/test/CodeGen/Thumb/pr35836_2.ll
Modified:
    llvm/branches/release_60/   (props changed)
    llvm/branches/release_60/include/llvm/CodeGen/TargetInstrInfo.h
    llvm/branches/release_60/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp
    llvm/branches/release_60/lib/Target/ARM/Thumb1InstrInfo.cpp
    llvm/branches/release_60/lib/Target/ARM/Thumb1InstrInfo.h

Propchange: llvm/branches/release_60/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Feb  2 05:35:26 2018
@@ -1,3 +1,3 @@
 /llvm/branches/Apple/Pertwee:110850,110961
 /llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:155241,321751,321789,321791,321806,321862,321870,321872,321878,321980,321991,321993-321994,322003,322016,322053,322056,322103,322106,322108,322123,322131,322223,322272,322313,322372,322473,322623,322644,322724,322767,322875,322878-322879,322900,322904-322905,322973,322993,323034,323155,323190,323307,323331,323355,323369,323371,323384,323469,323515,323582,323671-323672,323706,323710,323810-323811,323813,323915
+/llvm/trunk:155241,321751,321789,321791,321806,321862,321870,321872,321878,321980,321991,321993-321994,322003,322016,322053,322056,322103,322106,322108,322123,322131,322223,322272,322313,322372,322473,322623,322644,322724,322767,322875,322878-322879,322900,322904-322905,322973,322993,323034,323155,323190,323307,323331,323355,323369,323371,323384,323469,323515,323582,323671-323672,323706,323710,323810-323811,323813,323857,323915

Modified: llvm/branches/release_60/include/llvm/CodeGen/TargetInstrInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_60/include/llvm/CodeGen/TargetInstrInfo.h?rev=324082&r1=324081&r2=324082&view=diff
==============================================================================
--- llvm/branches/release_60/include/llvm/CodeGen/TargetInstrInfo.h (original)
+++ llvm/branches/release_60/include/llvm/CodeGen/TargetInstrInfo.h Fri Feb  2 05:35:26 2018
@@ -950,6 +950,10 @@ public:
   /// Return true when a target supports MachineCombiner.
   virtual bool useMachineCombiner() const { return false; }
 
+  /// Return true if the given SDNode can be copied during scheduling
+  /// even if it has glue.
+  virtual bool canCopyGluedNodeDuringSchedule(SDNode *N) const { return false; }
+
 protected:
   /// Target-dependent implementation for foldMemoryOperand.
   /// Target-independent code in foldMemoryOperand will

Modified: llvm/branches/release_60/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_60/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp?rev=324082&r1=324081&r2=324082&view=diff
==============================================================================
--- llvm/branches/release_60/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp (original)
+++ llvm/branches/release_60/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp Fri Feb  2 05:35:26 2018
@@ -1117,22 +1117,34 @@ SUnit *ScheduleDAGRRList::CopyAndMoveSuc
   if (!N)
     return nullptr;
 
-  if (SU->getNode()->getGluedNode())
+  DEBUG(dbgs() << "Considering duplicating the SU\n");
+  DEBUG(SU->dump(this));
+
+  if (N->getGluedNode() &&
+      !TII->canCopyGluedNodeDuringSchedule(N)) {
+    DEBUG(dbgs()
+        << "Giving up because it has incoming glue and the target does not "
+           "want to copy it\n");
     return nullptr;
+  }
 
   SUnit *NewSU;
   bool TryUnfold = false;
   for (unsigned i = 0, e = N->getNumValues(); i != e; ++i) {
     MVT VT = N->getSimpleValueType(i);
-    if (VT == MVT::Glue)
+    if (VT == MVT::Glue) {
+      DEBUG(dbgs() << "Giving up because it has outgoing glue\n");
       return nullptr;
-    else if (VT == MVT::Other)
+    } else if (VT == MVT::Other)
       TryUnfold = true;
   }
   for (const SDValue &Op : N->op_values()) {
     MVT VT = Op.getNode()->getSimpleValueType(Op.getResNo());
-    if (VT == MVT::Glue)
+    if (VT == MVT::Glue && !TII->canCopyGluedNodeDuringSchedule(N)) {
+      DEBUG(dbgs() << "Giving up because it one of the operands is glue and "
+                      "the target does not want to copy it\n");
       return nullptr;
+    }
   }
 
   // If possible unfold instruction.

Modified: llvm/branches/release_60/lib/Target/ARM/Thumb1InstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_60/lib/Target/ARM/Thumb1InstrInfo.cpp?rev=324082&r1=324081&r2=324082&view=diff
==============================================================================
--- llvm/branches/release_60/lib/Target/ARM/Thumb1InstrInfo.cpp (original)
+++ llvm/branches/release_60/lib/Target/ARM/Thumb1InstrInfo.cpp Fri Feb  2 05:35:26 2018
@@ -141,3 +141,16 @@ void Thumb1InstrInfo::expandLoadStackGua
   else
     expandLoadStackGuardBase(MI, ARM::tLDRLIT_ga_abs, ARM::tLDRi);
 }
+
+bool Thumb1InstrInfo::canCopyGluedNodeDuringSchedule(SDNode *N) const {
+  // In Thumb1 the scheduler may need to schedule a cross-copy between GPRS and CPSR
+  // but this is not always possible there, so allow the Scheduler to clone tADCS and tSBCS
+  // even if they have glue.
+  // FIXME. Actually implement the cross-copy where it is possible (post v6)
+  // because these copies entail more spilling.
+  unsigned Opcode = N->getMachineOpcode();
+  if (Opcode == ARM::tADCS || Opcode == ARM::tSBCS)
+    return true;
+
+  return false;
+}

Modified: llvm/branches/release_60/lib/Target/ARM/Thumb1InstrInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_60/lib/Target/ARM/Thumb1InstrInfo.h?rev=324082&r1=324081&r2=324082&view=diff
==============================================================================
--- llvm/branches/release_60/lib/Target/ARM/Thumb1InstrInfo.h (original)
+++ llvm/branches/release_60/lib/Target/ARM/Thumb1InstrInfo.h Fri Feb  2 05:35:26 2018
@@ -53,6 +53,7 @@ public:
                             const TargetRegisterClass *RC,
                             const TargetRegisterInfo *TRI) const override;
 
+  bool canCopyGluedNodeDuringSchedule(SDNode *N) const override;
 private:
   void expandLoadStackGuard(MachineBasicBlock::iterator MI) const override;
 };




More information about the llvm-branch-commits mailing list