[PATCH] D118773: [MachineLICM] Add shouldHoist method to TargetInstrInfo

Carl Ritson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 2 03:51:59 PST 2022


critson created this revision.
critson added reviewers: foad, qcolombet, rampitec.
Herald added subscribers: asbirlea, hiraditya.
critson requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Add a shouldHoist method to TargetInstrInfo which is queried by
MachineLICM to override hoisting decisions for a given target.
This mirrors functionality provided by shouldSink.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D118773

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
@@ -999,6 +999,9 @@
   if (I.isConvergent())
     return false;
 
+  if (!TII->shouldHoist(I, CurLoop))
+    return false;
+
   return true;
 }
 
Index: llvm/include/llvm/CodeGen/TargetInstrInfo.h
===================================================================
--- llvm/include/llvm/CodeGen/TargetInstrInfo.h
+++ llvm/include/llvm/CodeGen/TargetInstrInfo.h
@@ -382,6 +382,16 @@
   /// to which instructions should be sunk.
   virtual bool shouldSink(const MachineInstr &MI) const { return true; }
 
+  /// Return true if the instruction should be hoisted by MachineLICM.
+  ///
+  /// MachineLICM determines on its own whether the instruction is safe to
+  /// hoist; this gives the target a hook to override the default behavior with
+  /// regards to which instructions should be hoisted from a given loop.
+  virtual bool shouldHoist(const MachineInstr &MI,
+                           const MachineLoop *FromLoop) const {
+    return true;
+  }
+
   /// Re-issue the specified 'original' instruction at the
   /// specific location targeting a new destination register.
   /// The register in Orig->getOperand(0).getReg() will be substituted by


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118773.405204.patch
Type: text/x-patch
Size: 1335 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220202/cb2d1a9b/attachment.bin>


More information about the llvm-commits mailing list