[llvm] 2a24d35 - [MachineCombine] add a hook for resource length limit
Chen Zheng via llvm-commits
llvm-commits at lists.llvm.org
Sun May 31 21:09:21 PDT 2020
Author: Chen Zheng
Date: 2020-05-31T23:21:04-04:00
New Revision: 2a24d350dbeacb131af91e8c438fed2bd81698c0
URL: https://github.com/llvm/llvm-project/commit/2a24d350dbeacb131af91e8c438fed2bd81698c0
DIFF: https://github.com/llvm/llvm-project/commit/2a24d350dbeacb131af91e8c438fed2bd81698c0.diff
LOG: [MachineCombine] add a hook for resource length limit
Added:
Modified:
llvm/include/llvm/CodeGen/TargetInstrInfo.h
llvm/lib/CodeGen/MachineCombiner.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/CodeGen/TargetInstrInfo.h b/llvm/include/llvm/CodeGen/TargetInstrInfo.h
index 8c6d84521594..709030b62076 100644
--- a/llvm/include/llvm/CodeGen/TargetInstrInfo.h
+++ b/llvm/include/llvm/CodeGen/TargetInstrInfo.h
@@ -1093,6 +1093,9 @@ class TargetInstrInfo : public MCInstrInfo {
SmallVectorImpl<MachineInstr *> &DelInstrs,
DenseMap<unsigned, unsigned> &InstrIdxForVirtReg) const;
+ /// The limit on resource length extension we accept in MachineCombiner Pass.
+ virtual int 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,
diff --git a/llvm/lib/CodeGen/MachineCombiner.cpp b/llvm/lib/CodeGen/MachineCombiner.cpp
index 73895bdf834f..34087d0491bd 100644
--- a/llvm/lib/CodeGen/MachineCombiner.cpp
+++ b/llvm/lib/CodeGen/MachineCombiner.cpp
@@ -406,12 +406,14 @@ bool MachineCombiner::preservesResourceLen(
<< ResLenBeforeCombine
<< " and after: " << ResLenAfterCombine << "\n";);
LLVM_DEBUG(
- ResLenAfterCombine <= ResLenBeforeCombine
+ ResLenAfterCombine <=
+ ResLenBeforeCombine + TII->getExtendResourceLenLimit()
? dbgs() << "\t\t As result it IMPROVES/PRESERVES Resource Length\n"
: 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
More information about the llvm-commits
mailing list