Skip to content

Commit 6cf3566

Browse files
authored
[NFC][MachineScheduler] Rename NumLoads parameter of shouldClusterMemOps to ClusterSize (#73757)
As the same hook is called for both load and store clustering, NumLoads is a misleading name. Use ClusterSize instead.
1 parent 6e01016 commit 6cf3566

File tree

7 files changed

+19
-14
lines changed

7 files changed

+19
-14
lines changed

llvm/include/llvm/CodeGen/TargetInstrInfo.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1496,13 +1496,14 @@ class TargetInstrInfo : public MCInstrInfo {
14961496
/// to TargetPassConfig::createMachineScheduler() to have an effect.
14971497
///
14981498
/// \p BaseOps1 and \p BaseOps2 are memory operands of two memory operations.
1499-
/// \p NumLoads is the number of loads that will be in the cluster if this
1500-
/// hook returns true.
1499+
/// \p ClusterSize is the number of operations in the resulting load/store
1500+
/// cluster if this hook returns true.
15011501
/// \p NumBytes is the number of bytes that will be loaded from all the
15021502
/// clustered loads if this hook returns true.
15031503
virtual bool shouldClusterMemOps(ArrayRef<const MachineOperand *> BaseOps1,
15041504
ArrayRef<const MachineOperand *> BaseOps2,
1505-
unsigned NumLoads, unsigned NumBytes) const {
1505+
unsigned ClusterSize,
1506+
unsigned NumBytes) const {
15061507
llvm_unreachable("target did not implement shouldClusterMemOps()");
15071508
}
15081509

llvm/lib/Target/AArch64/AArch64InstrInfo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4231,7 +4231,7 @@ static bool shouldClusterFI(const MachineFrameInfo &MFI, int FI1,
42314231
/// Only called for LdSt for which getMemOperandWithOffset returns true.
42324232
bool AArch64InstrInfo::shouldClusterMemOps(
42334233
ArrayRef<const MachineOperand *> BaseOps1,
4234-
ArrayRef<const MachineOperand *> BaseOps2, unsigned NumLoads,
4234+
ArrayRef<const MachineOperand *> BaseOps2, unsigned ClusterSize,
42354235
unsigned NumBytes) const {
42364236
assert(BaseOps1.size() == 1 && BaseOps2.size() == 1);
42374237
const MachineOperand &BaseOp1 = *BaseOps1.front();
@@ -4249,7 +4249,7 @@ bool AArch64InstrInfo::shouldClusterMemOps(
42494249
return false;
42504250

42514251
// Only cluster up to a single pair.
4252-
if (NumLoads > 2)
4252+
if (ClusterSize > 2)
42534253
return false;
42544254

42554255
if (!isPairableLdStInst(FirstLdSt) || !isPairableLdStInst(SecondLdSt))

llvm/lib/Target/AArch64/AArch64InstrInfo.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,8 @@ class AArch64InstrInfo final : public AArch64GenInstrInfo {
180180

181181
bool shouldClusterMemOps(ArrayRef<const MachineOperand *> BaseOps1,
182182
ArrayRef<const MachineOperand *> BaseOps2,
183-
unsigned NumLoads, unsigned NumBytes) const override;
183+
unsigned ClusterSize,
184+
unsigned NumBytes) const override;
184185

185186
void copyPhysRegTuple(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
186187
const DebugLoc &DL, MCRegister DestReg,

llvm/lib/Target/AMDGPU/SIInstrInfo.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ static bool memOpsHaveSameBasePtr(const MachineInstr &MI1,
542542

543543
bool SIInstrInfo::shouldClusterMemOps(ArrayRef<const MachineOperand *> BaseOps1,
544544
ArrayRef<const MachineOperand *> BaseOps2,
545-
unsigned NumLoads,
545+
unsigned ClusterSize,
546546
unsigned NumBytes) const {
547547
// If the mem ops (to be clustered) do not have the same base ptr, then they
548548
// should not be clustered
@@ -568,8 +568,8 @@ bool SIInstrInfo::shouldClusterMemOps(ArrayRef<const MachineOperand *> BaseOps1,
568568
// (3) 9 <= LoadSize <= 12: cluster at max 2 mem ops
569569
// (4) 13 <= LoadSize <= 16: cluster at max 2 mem ops
570570
// (5) LoadSize >= 17: do not cluster
571-
const unsigned LoadSize = NumBytes / NumLoads;
572-
const unsigned NumDWORDs = ((LoadSize + 3) / 4) * NumLoads;
571+
const unsigned LoadSize = NumBytes / ClusterSize;
572+
const unsigned NumDWORDs = ((LoadSize + 3) / 4) * ClusterSize;
573573
return NumDWORDs <= 8;
574574
}
575575

llvm/lib/Target/AMDGPU/SIInstrInfo.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,8 @@ class SIInstrInfo final : public AMDGPUGenInstrInfo {
235235

236236
bool shouldClusterMemOps(ArrayRef<const MachineOperand *> BaseOps1,
237237
ArrayRef<const MachineOperand *> BaseOps2,
238-
unsigned NumLoads, unsigned NumBytes) const override;
238+
unsigned ClusterSize,
239+
unsigned NumBytes) const override;
239240

240241
bool shouldScheduleLoadsNear(SDNode *Load0, SDNode *Load1, int64_t Offset0,
241242
int64_t Offset1, unsigned NumLoads) const override;

llvm/lib/Target/PowerPC/PPCInstrInfo.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2879,7 +2879,7 @@ static bool isClusterableLdStOpcPair(unsigned FirstOpc, unsigned SecondOpc,
28792879

28802880
bool PPCInstrInfo::shouldClusterMemOps(
28812881
ArrayRef<const MachineOperand *> BaseOps1,
2882-
ArrayRef<const MachineOperand *> BaseOps2, unsigned NumLoads,
2882+
ArrayRef<const MachineOperand *> BaseOps2, unsigned ClusterSize,
28832883
unsigned NumBytes) const {
28842884

28852885
assert(BaseOps1.size() == 1 && BaseOps2.size() == 1);
@@ -2888,9 +2888,10 @@ bool PPCInstrInfo::shouldClusterMemOps(
28882888
assert((BaseOp1.isReg() || BaseOp1.isFI()) &&
28892889
"Only base registers and frame indices are supported.");
28902890

2891-
// The NumLoads means the number of loads that has been clustered.
2891+
// ClusterSize means the number of memory operations that will have been
2892+
// clustered if this hook returns true.
28922893
// Don't cluster memory op if there are already two ops clustered at least.
2893-
if (NumLoads > 2)
2894+
if (ClusterSize > 2)
28942895
return false;
28952896

28962897
// Cluster the load/store only when they have the same base

llvm/lib/Target/PowerPC/PPCInstrInfo.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,8 @@ class PPCInstrInfo : public PPCGenInstrInfo {
531531
/// adjacent.
532532
bool shouldClusterMemOps(ArrayRef<const MachineOperand *> BaseOps1,
533533
ArrayRef<const MachineOperand *> BaseOps2,
534-
unsigned NumLoads, unsigned NumBytes) const override;
534+
unsigned ClusterSize,
535+
unsigned NumBytes) const override;
535536

536537
/// Return true if two MIs access different memory addresses and false
537538
/// otherwise

0 commit comments

Comments
 (0)