[GreedyRA ORE] Re-factor computeNumberOfSplillsReloads.

Replace if-else to if-continue usage.
This simplifies further extension of the collected stats.
This commit is contained in:
Serguei Katkov 2021-04-09 11:29:35 +07:00
parent f4eb681dc3
commit f6e3b4fe58
1 changed files with 19 additions and 11 deletions

View File

@ -3146,23 +3146,31 @@ RAGreedy::computeNumberOfSplillsReloads(MachineBasicBlock &MBB) {
const MachineFrameInfo &MFI = MF->getFrameInfo();
int FI;
auto isSpillSlotAccess = [&MFI](const MachineMemOperand *A) {
return MFI.isSpillSlotObjectIndex(cast<FixedStackPseudoSourceValue>(
A->getPseudoValue())->getFrameIndex());
};
for (MachineInstr &MI : MBB) {
SmallVector<const MachineMemOperand *, 2> Accesses;
auto isSpillSlotAccess = [&MFI](const MachineMemOperand *A) {
return MFI.isSpillSlotObjectIndex(cast<FixedStackPseudoSourceValue>(
A->getPseudoValue())->getFrameIndex());
};
if (TII->isLoadFromStackSlot(MI, FI) && MFI.isSpillSlotObjectIndex(FI))
if (TII->isLoadFromStackSlot(MI, FI) && MFI.isSpillSlotObjectIndex(FI)) {
++Stats.Reloads;
else if (TII->hasLoadFromStackSlot(MI, Accesses) &&
llvm::any_of(Accesses, isSpillSlotAccess))
++Stats.FoldedReloads;
else if (TII->isStoreToStackSlot(MI, FI) && MFI.isSpillSlotObjectIndex(FI))
continue;
}
if (TII->isStoreToStackSlot(MI, FI) && MFI.isSpillSlotObjectIndex(FI)) {
++Stats.Spills;
else if (TII->hasStoreToStackSlot(MI, Accesses) &&
llvm::any_of(Accesses, isSpillSlotAccess))
continue;
}
if (TII->hasLoadFromStackSlot(MI, Accesses) &&
llvm::any_of(Accesses, isSpillSlotAccess)) {
++Stats.FoldedReloads;
continue;
}
Accesses.clear();
if (TII->hasStoreToStackSlot(MI, Accesses) &&
llvm::any_of(Accesses, isSpillSlotAccess)) {
++Stats.FoldedSpills;
}
}
return Stats;
}