[llvm] [AMDGPU][SIPreEmitPeephole] mustRetainExeczBranch: use BranchProbability and TargetSchedmodel (PR #109818)
Juan Manuel Martinez CaamaƱo via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 2 08:07:11 PDT 2024
================
@@ -326,23 +377,22 @@ bool SIPreEmitPeephole::mustRetainExeczBranch(
if (TII->hasUnwantedEffectsWhenEXECEmpty(MI))
return true;
- // These instructions are potentially expensive even if EXEC = 0.
- if (TII->isSMRD(MI) || TII->isVMEM(MI) || TII->isFLAT(MI) ||
- TII->isDS(MI) || TII->isWaitcnt(MI.getOpcode()))
- return true;
-
- ++NumInstr;
- if (NumInstr >= SkipThreshold)
+ if (!CostModel.isProfitable(MI))
return true;
}
}
return false;
}
+} // namespace
// Returns true if the skip branch instruction is removed.
bool SIPreEmitPeephole::removeExeczBranch(MachineInstr &MI,
MachineBasicBlock &SrcMBB) {
+
+ if (!TII->getSchedModel().hasInstrSchedModelOrItineraries())
----------------
jmmartinez wrote:
It seems it's owned by the TII. The `TargetSchedModel` only needs the subtarget for initialization, so it would make sense for it to be a member of the subtarget.
We can move it to the `GCNSubtarget` (it would still be accessible to the TII through the subtarget to be used in `SIInstrInfo::getInstrLatency`).
Additionally, some passes are allocating their own `TargetSchedModel` while they could reference the one allocated by the TII: `GCNHazardRecognizer` and `AMDGPUInsertDelayAlu`. I fixed this in https://github.com/llvm/llvm-project/pull/110859
https://github.com/llvm/llvm-project/pull/109818
More information about the llvm-commits
mailing list