[PATCH] D82441: [MachineLICM] NFC - add a target hook shouldHoistCheapInstructions for machine licm to hoist cheap instruction

ChenZheng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 28 01:42:27 PDT 2020


shchenz updated this revision to Diff 273907.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82441/new/

https://reviews.llvm.org/D82441

Files:
  llvm/include/llvm/CodeGen/TargetInstrInfo.h
  llvm/lib/CodeGen/MachineLICM.cpp


Index: llvm/lib/CodeGen/MachineLICM.cpp
===================================================================
--- llvm/lib/CodeGen/MachineLICM.cpp
+++ llvm/lib/CodeGen/MachineLICM.cpp
@@ -1205,9 +1205,9 @@
     unsigned Class = RPIdAndCost.first;
     int Limit = RegLimit[Class];
 
-    // Don't hoist cheap instructions if they would increase register pressure,
-    // even if we're under the limit.
-    if (CheapInstr && !HoistCheapInsts)
+    // If target prefers not to hoist cheap instructions, don't hoist them, even
+    // if we're under the limit.
+    if (CheapInstr && !HoistCheapInsts && !TII->shouldHoistCheapInstructions())
       return true;
 
     for (const auto &RP : BackTrace)
Index: llvm/include/llvm/CodeGen/TargetInstrInfo.h
===================================================================
--- llvm/include/llvm/CodeGen/TargetInstrInfo.h
+++ llvm/include/llvm/CodeGen/TargetInstrInfo.h
@@ -1531,6 +1531,10 @@
                                 const MachineInstr &DefMI,
                                 unsigned DefIdx) const;
 
+  /// Specify whether a target should hoist cheap instructions based on
+  /// register pressure.
+  virtual bool shouldHoistCheapInstructions() const { return false; }
+
   /// Perform target-specific instruction verification.
   virtual bool verifyInstruction(const MachineInstr &MI,
                                  StringRef &ErrInfo) const {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82441.273907.patch
Type: text/x-patch
Size: 1405 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200628/ccd1ad3c/attachment.bin>


More information about the llvm-commits mailing list