Skip to content

Commit 379d74d

Browse files
author
Shimin Cui
committed
Address Eli's comments
1 parent fbfd109 commit 379d74d

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

llvm/include/llvm/CodeGen/TargetLowering.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,10 +1441,9 @@ class LLVM_ABI TargetLoweringBase {
14411441
/// \p High as its lowest and highest case values, and expects \p NumCmps
14421442
/// case value comparisons. Check if the number of destinations, comparison
14431443
/// metric, and range are all suitable.
1444-
bool
1445-
isSuitableForBitTests(DenseMap<const BasicBlock *, unsigned int> DestCmps,
1446-
const APInt &Low, const APInt &High,
1447-
const DataLayout &DL) const {
1444+
bool isSuitableForBitTests(
1445+
const DenseMap<const BasicBlock *, unsigned int> DestCmps,
1446+
const APInt &Low, const APInt &High, const DataLayout &DL) const {
14481447
// FIXME: I don't think NumCmps is the correct metric: a single case and a
14491448
// range of cases both require only one branch to lower. Just looking at the
14501449
// number of clusters and destinations should be enough to decide whether to
@@ -3726,6 +3725,9 @@ class LLVM_ABI TargetLoweringBase {
37263725
/// backend supports.
37273726
unsigned MinCmpXchgSizeInBits;
37283727

3728+
/// The minimum of largest number of comparisons to use bit test for switch.
3729+
unsigned MinimumBitTestCmps;
3730+
37293731
/// This indicates if the target supports unaligned atomic operations.
37303732
bool SupportsUnalignedAtomics;
37313733

llvm/lib/CodeGen/SwitchLoweringUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ bool SwitchCG::SwitchLowering::buildBitTests(CaseClusterVector &Clusters,
379379
assert(Clusters[I].Kind == CC_Range);
380380
unsigned NumCmp = (Clusters[I].Low == Clusters[I].High) ? 1 : 2;
381381
const BasicBlock *BB = Clusters[I].MBB->getBasicBlock();
382-
DestMap[BB] = DestMap.count(BB) ? (DestMap[BB] + NumCmp) : NumCmp;
382+
DestMap[BB] += NumCmp;
383383
}
384384

385385
APInt Low = Clusters[First].Low->getValue();

llvm/lib/CodeGen/TargetLoweringBase.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ static cl::opt<unsigned> OptsizeJumpTableDensity(
9191
cl::desc("Minimum density for building a jump table in "
9292
"an optsize function"));
9393

94-
static cl::opt<unsigned>
95-
MinimumBitTestCmps("min-bit-test-cmps", cl::init(2), cl::Hidden,
96-
cl::desc("Set minimum of largest number of comparisons "
97-
"to use bit test for switch."));
94+
static cl::opt<unsigned> MinimumBitTestCmpsOverride(
95+
"min-bit-test-cmps", cl::init(2), cl::Hidden,
96+
cl::desc("Set minimum of largest number of comparisons "
97+
"to use bit test for switch."));
9898

9999
// FIXME: This option is only to test if the strict fp operation processed
100100
// correctly by preventing mutating strict fp operation to normal fp operation
@@ -725,6 +725,8 @@ TargetLoweringBase::TargetLoweringBase(const TargetMachine &tm)
725725

726726
MinCmpXchgSizeInBits = 0;
727727
SupportsUnalignedAtomics = false;
728+
729+
MinimumBitTestCmps = MinimumBitTestCmpsOverride;
728730
}
729731

730732
// Define the virtual destructor out-of-line to act as a key method to anchor

0 commit comments

Comments
 (0)