[PATCH] D80604: [MachineCombiner] add a hook to allow some extension for resource length - NFC

ChenZheng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 26 20:10:16 PDT 2020


shchenz created this revision.
shchenz added reviewers: spatel, fhahn, RKSimon, hfinkel, jsji.
Herald added subscribers: llvm-commits, wuzish, hiraditya.
Herald added a project: LLVM.

Currently `preservesResourceLen` in machine combiner pass requires that new instructions resource length is not bigger than old instructions resource length.

I think this is ok if size of new instructions is not bigger than size of old instructions. For now I think all reassociations in machine combiner pass meets this condition.

But in patch https://reviews.llvm.org/D80175, we add a new reassociation that combines `fma + fma + fma` to `(fmul + fma + fma + fadd)`, this will cause callee in `getResourceLength`, `getCycles` sometimes return same resource length for new and old instructions and sometimes new resource length is 1 bigger than old resource length.

Add this hook to make it target specific to accept some extension in resource length but we may still benefit from reducing in data depth.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80604

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


Index: llvm/lib/CodeGen/MachineCombiner.cpp
===================================================================
--- llvm/lib/CodeGen/MachineCombiner.cpp
+++ llvm/lib/CodeGen/MachineCombiner.cpp
@@ -411,7 +411,8 @@
           : dbgs() << "\t\t  As result it DOES NOT improve/preserve Resource "
                       "Length\n");
 
-  return ResLenAfterCombine <= ResLenBeforeCombine;
+  return ResLenAfterCombine <=
+         ResLenBeforeCombine + TII->getExtendResourceLenLimit();
 }
 
 /// \returns true when new instruction sequence should be generated
Index: llvm/include/llvm/CodeGen/TargetInstrInfo.h
===================================================================
--- llvm/include/llvm/CodeGen/TargetInstrInfo.h
+++ llvm/include/llvm/CodeGen/TargetInstrInfo.h
@@ -1095,6 +1095,9 @@
                       SmallVectorImpl<MachineInstr *> &DelInstrs,
                       DenseMap<unsigned, unsigned> &InstrIdxForVirtReg) const;
 
+  /// The limit on resource length extension we accept in MachineCombiner Pass.
+  virtual int16_t getExtendResourceLenLimit() const { return 0; }
+
   /// This is an architecture-specific helper function of reassociateOps.
   /// Set special operand attributes for new instructions after reassociation.
   virtual void setSpecialOperandAttr(MachineInstr &OldMI1, MachineInstr &OldMI2,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80604.266397.patch
Type: text/x-patch
Size: 1330 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200527/412717ce/attachment.bin>


More information about the llvm-commits mailing list