Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions llvm/lib/CodeGen/GlobalISel/RegBankSelect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@

using namespace llvm;

/// Cost value representing an impossible or invalid repairing.
/// This matches the value returned by RegisterBankInfo::copyCost() and
/// RegisterBankInfo::getBreakDownCost() when the cost cannot be computed.
static constexpr unsigned ImpossibleRepairCost =
std::numeric_limits<unsigned>::max();

static cl::opt<RegBankSelect::Mode> RegBankSelectMode(
cl::desc("Mode of the RegBankSelect pass"), cl::Hidden, cl::Optional,
cl::values(clEnumValN(RegBankSelect::Mode::Fast, "regbankselect-fast",
Expand Down Expand Up @@ -278,12 +284,11 @@ uint64_t RegBankSelect::getRepairCost(
// repairing placement.
unsigned Cost = RBI->copyCost(*DesiredRegBank, *CurRegBank,
RBI->getSizeInBits(MO.getReg(), *MRI, *TRI));
// TODO: use a dedicated constant for ImpossibleCost.
if (Cost != std::numeric_limits<unsigned>::max())
if (Cost != ImpossibleRepairCost)
return Cost;
// Return the legalization cost of that repairing.
}
return std::numeric_limits<unsigned>::max();
return ImpossibleRepairCost;
}

const RegisterBankInfo::InstructionMapping &RegBankSelect::findBestMapping(
Expand Down Expand Up @@ -535,7 +540,7 @@ RegBankSelect::MappingCost RegBankSelect::computeMapping(
uint64_t RepairCost = getRepairCost(MO, ValMapping);

// This is an impossible to repair cost.
if (RepairCost == std::numeric_limits<unsigned>::max())
if (RepairCost == ImpossibleRepairCost)
return MappingCost::ImpossibleCost();

// Bias used for splitting: 5%.
Expand Down
Loading