[MachineLICM] Add shouldHoist method to TargetInstrInfo

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.

Reviewed By: foad

Differential Revision: https://reviews.llvm.org/D118773
This commit is contained in:
Carl Ritson 2022-02-08 15:01:07 +09:00
parent fe2f5c976c
commit 42ac4e1a12
2 changed files with 14 additions and 0 deletions

View File

@ -382,6 +382,17 @@ public:
/// to which instructions should be sunk.
virtual bool shouldSink(const MachineInstr &MI) const { return true; }
/// Return false if the instruction should not be hoisted by MachineLICM.
///
/// MachineLICM determines on its own whether the instruction is safe to
/// hoist; this gives the target a hook to extend this assessment and prevent
/// an instruction being hoisted from a given loop for target specific
/// reasons.
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

View File

@ -999,6 +999,9 @@ bool MachineLICMBase::IsLICMCandidate(MachineInstr &I) {
if (I.isConvergent())
return false;
if (!TII->shouldHoist(I, CurLoop))
return false;
return true;
}