Skip to content

Commit e60c54f

Browse files
committed
!fixup address latest comments, thanks!
1 parent 5b4197c commit e60c54f

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12322,14 +12322,15 @@ void SelectionDAGBuilder::lowerWorkItem(SwitchWorkListItem W, Value *Cond,
1232212322
case CC_Range: {
1232312323
const Value *RHS, *LHS, *MHS;
1232412324
ISD::CondCode CC;
12325-
if (I->Low == I->High || I->Kind == CC_And) {
12325+
if (I->Low == I->High) {
1232612326
// Check Cond == I->Low.
1232712327
CC = ISD::SETEQ;
1232812328
LHS = Cond;
1232912329
RHS=I->Low;
1233012330
MHS = nullptr;
1233112331
} else {
1233212332
// Check I->Low <= Cond <= I->High.
12333+
assert(I->Kind != CC_And && "CC_And must be handled above");
1233312334
CC = ISD::SETLE;
1233412335
LHS = I->Low;
1233512336
MHS = Cond;

llvm/lib/CodeGen/SwitchLoweringUtils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ void SwitchCG::SwitchLowering::findBitTestClusters(CaseClusterVector &Clusters,
365365

366366
// Check if the clusters contain one checking for 0 and another one checking
367367
// for a power-of-2 constant with matching destinations. Those clusters can be
368-
// combined to a single ane with CC_And.
368+
// combined to a single one with CC_And.
369369
unsigned ZeroIdx = -1;
370370
for (const auto &[Idx, C] : enumerate(Clusters)) {
371371
if (C.Kind != CC_Range || C.Low != C.High)
@@ -391,7 +391,7 @@ void SwitchCG::SwitchLowering::findBitTestClusters(CaseClusterVector &Clusters,
391391
return;
392392

393393
APInt Pow2 = Clusters[Pow2Idx].Low->getValue();
394-
APInt NewC = (Pow2 + 1) * -1;
394+
APInt NewC = ~Pow2;
395395
Clusters[ZeroIdx].Low = ConstantInt::get(SI->getContext(), NewC);
396396
Clusters[ZeroIdx].High = ConstantInt::get(SI->getContext(), NewC);
397397
Clusters[ZeroIdx].Kind = CC_And;

0 commit comments

Comments
 (0)