Skip to content

Commit e69d402

Browse files
[NFC] rename member of BitTestBlock and JumpTableHeader
Follow up to suggestions in D109103 via hans: I think UnreachableDefault (or UnreachableFallthrough) would be a better name now, since it doesn't just omit the range check, it also omits the last bit test. Reviewed By: hans Differential Revision: https://reviews.llvm.org/D109455
1 parent f40bba4 commit e69d402

File tree

4 files changed

+22
-28
lines changed

4 files changed

+22
-28
lines changed

llvm/include/llvm/CodeGen/SwitchLoweringUtils.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,12 @@ struct JumpTableHeader {
183183
const Value *SValue;
184184
MachineBasicBlock *HeaderBB;
185185
bool Emitted;
186-
bool OmitRangeCheck;
186+
bool FallthroughUnreachable;
187187

188188
JumpTableHeader(APInt F, APInt L, const Value *SV, MachineBasicBlock *H,
189189
bool E = false)
190190
: First(std::move(F)), Last(std::move(L)), SValue(SV), HeaderBB(H),
191-
Emitted(E), OmitRangeCheck(false) {}
191+
Emitted(E), FallthroughUnreachable(false) {}
192192
};
193193
using JumpTableBlock = std::pair<JumpTableHeader, JumpTable>;
194194

@@ -218,14 +218,14 @@ struct BitTestBlock {
218218
BitTestInfo Cases;
219219
BranchProbability Prob;
220220
BranchProbability DefaultProb;
221-
bool OmitRangeCheck;
221+
bool FallthroughUnreachable;
222222

223223
BitTestBlock(APInt F, APInt R, const Value *SV, unsigned Rg, MVT RgVT, bool E,
224224
bool CR, MachineBasicBlock *P, MachineBasicBlock *D,
225225
BitTestInfo C, BranchProbability Pr)
226226
: First(std::move(F)), Range(std::move(R)), SValue(SV), Reg(Rg),
227227
RegVT(RgVT), Emitted(E), ContiguousRange(CR), Parent(P), Default(D),
228-
Cases(std::move(C)), Prob(Pr), OmitRangeCheck(false) {}
228+
Cases(std::move(C)), Prob(Pr), FallthroughUnreachable(false) {}
229229
};
230230

231231
/// Return the range of values within a range.

llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ bool IRTranslator::emitJumpTableHeader(SwitchCG::JumpTable &JT,
785785

786786
JT.Reg = Sub.getReg(0);
787787

788-
if (JTH.OmitRangeCheck) {
788+
if (JTH.FallthroughUnreachable) {
789789
if (JT.MBB != HeaderBB->getNextNode())
790790
MIB.buildBr(*JT.MBB);
791791
return true;
@@ -937,11 +937,10 @@ bool IRTranslator::lowerJumpTableWorkItem(SwitchCG::SwitchWorkListItem W,
937937
}
938938
}
939939

940-
// Skip the range check if the fallthrough block is unreachable.
941940
if (FallthroughUnreachable)
942-
JTH->OmitRangeCheck = true;
941+
JTH->FallthroughUnreachable = true;
943942

944-
if (!JTH->OmitRangeCheck)
943+
if (!JTH->FallthroughUnreachable)
945944
addSuccessorWithProb(CurMBB, Fallthrough, FallthroughProb);
946945
addSuccessorWithProb(CurMBB, JumpMBB, JumpProb);
947946
CurMBB->normalizeSuccProbs();
@@ -1024,13 +1023,13 @@ void IRTranslator::emitBitTestHeader(SwitchCG::BitTestBlock &B,
10241023

10251024
MachineBasicBlock *MBB = B.Cases[0].ThisBB;
10261025

1027-
if (!B.OmitRangeCheck)
1026+
if (!B.FallthroughUnreachable)
10281027
addSuccessorWithProb(SwitchBB, B.Default, B.DefaultProb);
10291028
addSuccessorWithProb(SwitchBB, MBB, B.Prob);
10301029

10311030
SwitchBB->normalizeSuccProbs();
10321031

1033-
if (!B.OmitRangeCheck) {
1032+
if (!B.FallthroughUnreachable) {
10341033
// Conditional branch to the default block.
10351034
auto RangeCst = MIB.buildConstant(SwitchOpTy, B.Range);
10361035
auto RangeCmp = MIB.buildICmp(CmpInst::Predicate::ICMP_UGT, LLT::scalar(1),
@@ -1130,10 +1129,8 @@ bool IRTranslator::lowerBitTestWorkItem(
11301129
BTB->DefaultProb -= DefaultProb / 2;
11311130
}
11321131

1133-
if (FallthroughUnreachable) {
1134-
// Skip the range check if the fallthrough block is unreachable.
1135-
BTB->OmitRangeCheck = true;
1136-
}
1132+
if (FallthroughUnreachable)
1133+
BTB->FallthroughUnreachable = true;
11371134

11381135
// If we're in the right place, emit the bit test header right now.
11391136
if (CurMBB == SwitchMBB) {
@@ -3019,7 +3016,7 @@ void IRTranslator::finalizeBasicBlock() {
30193016
// test, and delete the last bit test.
30203017

30213018
MachineBasicBlock *NextMBB;
3022-
if ((BTB.ContiguousRange || BTB.OmitRangeCheck) && j + 2 == ej) {
3019+
if ((BTB.ContiguousRange || BTB.FallthroughUnreachable) && j + 2 == ej) {
30233020
// Second-to-last bit-test with contiguous range: fall through to the
30243021
// target of the final bit test.
30253022
NextMBB = BTB.Cases[j + 1].TargetBB;
@@ -3033,7 +3030,7 @@ void IRTranslator::finalizeBasicBlock() {
30333030

30343031
emitBitTestCase(BTB, NextMBB, UnhandledProb, BTB.Reg, BTB.Cases[j], MBB);
30353032

3036-
if ((BTB.ContiguousRange || BTB.OmitRangeCheck) && j + 2 == ej) {
3033+
if ((BTB.ContiguousRange || BTB.FallthroughUnreachable) && j + 2 == ej) {
30373034
// We need to record the replacement phi edge here that normally
30383035
// happens in emitBitTestCase before we delete the case, otherwise the
30393036
// phi edge will be lost.

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2572,7 +2572,7 @@ void SelectionDAGBuilder::visitJumpTableHeader(SwitchCG::JumpTable &JT,
25722572
JumpTableReg, SwitchOp);
25732573
JT.Reg = JumpTableReg;
25742574

2575-
if (!JTH.OmitRangeCheck) {
2575+
if (!JTH.FallthroughUnreachable) {
25762576
// Emit the range check for the jump table, and branch to the default block
25772577
// for the switch statement if the value being switched on exceeds the
25782578
// largest case in the switch.
@@ -2784,13 +2784,13 @@ void SelectionDAGBuilder::visitBitTestHeader(BitTestBlock &B,
27842784

27852785
MachineBasicBlock* MBB = B.Cases[0].ThisBB;
27862786

2787-
if (!B.OmitRangeCheck)
2787+
if (!B.FallthroughUnreachable)
27882788
addSuccessorWithProb(SwitchBB, B.Default, B.DefaultProb);
27892789
addSuccessorWithProb(SwitchBB, MBB, B.Prob);
27902790
SwitchBB->normalizeSuccProbs();
27912791

27922792
SDValue Root = CopyTo;
2793-
if (!B.OmitRangeCheck) {
2793+
if (!B.FallthroughUnreachable) {
27942794
// Conditional branch to the default block.
27952795
SDValue RangeCmp = DAG.getSetCC(dl,
27962796
TLI.getSetCCResultType(DAG.getDataLayout(), *DAG.getContext(),
@@ -10826,12 +10826,10 @@ void SelectionDAGBuilder::lowerWorkItem(SwitchWorkListItem W, Value *Cond,
1082610826
}
1082710827
}
1082810828

10829-
if (FallthroughUnreachable) {
10830-
// Skip the range check if the fallthrough block is unreachable.
10831-
JTH->OmitRangeCheck = true;
10832-
}
10829+
if (FallthroughUnreachable)
10830+
JTH->FallthroughUnreachable = true;
1083310831

10834-
if (!JTH->OmitRangeCheck)
10832+
if (!JTH->FallthroughUnreachable)
1083510833
addSuccessorWithProb(CurMBB, Fallthrough, FallthroughProb);
1083610834
addSuccessorWithProb(CurMBB, JumpMBB, JumpProb);
1083710835
CurMBB->normalizeSuccProbs();
@@ -10869,9 +10867,8 @@ void SelectionDAGBuilder::lowerWorkItem(SwitchWorkListItem W, Value *Cond,
1086910867
BTB->DefaultProb -= DefaultProb / 2;
1087010868
}
1087110869

10872-
// Skip the range check if the fallthrough block is unreachable.
1087310870
if (FallthroughUnreachable)
10874-
BTB->OmitRangeCheck = true;
10871+
BTB->FallthroughUnreachable = true;
1087510872

1087610873
// If we're in the right place, emit the bit test header right now.
1087710874
if (CurMBB == SwitchMBB) {

llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1864,7 +1864,7 @@ SelectionDAGISel::FinishBasicBlock() {
18641864
// test, and delete the last bit test.
18651865

18661866
MachineBasicBlock *NextMBB;
1867-
if ((BTB.ContiguousRange || BTB.OmitRangeCheck) && j + 2 == ej) {
1867+
if ((BTB.ContiguousRange || BTB.FallthroughUnreachable) && j + 2 == ej) {
18681868
// Second-to-last bit-test with contiguous range or omitted range
18691869
// check: fall through to the target of the final bit test.
18701870
NextMBB = BTB.Cases[j + 1].TargetBB;
@@ -1883,7 +1883,7 @@ SelectionDAGISel::FinishBasicBlock() {
18831883
SDB->clear();
18841884
CodeGenAndEmitDAG();
18851885

1886-
if ((BTB.ContiguousRange || BTB.OmitRangeCheck) && j + 2 == ej) {
1886+
if ((BTB.ContiguousRange || BTB.FallthroughUnreachable) && j + 2 == ej) {
18871887
// Since we're not going to use the final bit test, remove it.
18881888
BTB.Cases.pop_back();
18891889
break;

0 commit comments

Comments
 (0)