From d1b92c91afd0be8939bddbf04f55ec53cf29227a Mon Sep 17 00:00:00 2001 From: Stanislav Mekhanoshin Date: Mon, 22 Feb 2021 12:25:30 -0800 Subject: [PATCH] [AMDGPU] Set threshold for regbanks reassign pass This is to limit compile time. I did experiments with some inputs and found that compile time keeps reasonable for this pass if we have less than 100000 virtual registers and then starts to explode somewhere between 100000 and 150000. Differential Revision: https://reviews.llvm.org/D97218 --- llvm/lib/Target/AMDGPU/GCNRegBankReassign.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/llvm/lib/Target/AMDGPU/GCNRegBankReassign.cpp b/llvm/lib/Target/AMDGPU/GCNRegBankReassign.cpp index 4fd76ba..137ac54 100644 --- a/llvm/lib/Target/AMDGPU/GCNRegBankReassign.cpp +++ b/llvm/lib/Target/AMDGPU/GCNRegBankReassign.cpp @@ -48,6 +48,11 @@ static cl::opt VerifyStallCycles("amdgpu-verify-regbanks-reassign", cl::value_desc("0|1|2"), cl::init(0), cl::Hidden); +// Threshold to keep compile time reasonable. +static cl::opt VRegThresh("amdgpu-regbanks-reassign-threshold", + cl::desc("Max number of vregs to run the regbanks reassign pass"), + cl::init(100000), cl::Hidden); + #define DEBUG_TYPE "amdgpu-regbanks-reassign" #define NUM_VGPR_BANKS 4 @@ -807,6 +812,16 @@ bool GCNRegBankReassign::runOnMachineFunction(MachineFunction &MF) { return false; MRI = &MF.getRegInfo(); + + LLVM_DEBUG(dbgs() << "=== RegBanks reassign analysis on function " << MF.getName() + << "\nNumVirtRegs = " << MRI->getNumVirtRegs() << "\n\n"); + + if (MRI->getNumVirtRegs() > VRegThresh) { + LLVM_DEBUG(dbgs() << "NumVirtRegs > " << VRegThresh + << " threshold, skipping function.\n\n"); + return false; + } + TRI = ST->getRegisterInfo(); MLI = &getAnalysis(); VRM = &getAnalysis(); @@ -826,9 +841,6 @@ bool GCNRegBankReassign::runOnMachineFunction(MachineFunction &MF) { AMDGPU::SReg_32RegClass.getNumRegs() / 2 + 1; RegsUsed.resize(NumRegBanks); - LLVM_DEBUG(dbgs() << "=== RegBanks reassign analysis on function " << MF.getName() - << '\n'); - unsigned StallCycles = collectCandidates(MF); NumStallsDetected += StallCycles; -- 2.7.4