Skip to content

Commit 35efc27

Browse files
committed
remove splitSwitchCases step
Signed-off-by: Nathan Gauër <[email protected]>
1 parent 82e9c14 commit 35efc27

File tree

1 file changed

+0
-41
lines changed

1 file changed

+0
-41
lines changed

llvm/lib/Target/SPIRV/SPIRVStructurizer.cpp

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,42 +1158,6 @@ class SPIRVStructurizer : public FunctionPass {
11581158
return Modified;
11591159
}
11601160

1161-
// Makes sure every case target in |F| is unique. If 2 cases branch to the
1162-
// same basic block, one of the targets is updated so it jumps to a new basic
1163-
// block ending with a single unconditional branch to the original target.
1164-
bool splitSwitchCases(Function &F) {
1165-
bool Modified = false;
1166-
1167-
for (BasicBlock &BB : F) {
1168-
SwitchInst *SI = dyn_cast<SwitchInst>(BB.getTerminator());
1169-
if (!SI)
1170-
continue;
1171-
1172-
BlockSet Seen;
1173-
Seen.insert(SI->getDefaultDest());
1174-
1175-
auto It = SI->case_begin();
1176-
while (It != SI->case_end()) {
1177-
BasicBlock *Target = It->getCaseSuccessor();
1178-
if (Seen.count(Target) == 0) {
1179-
Seen.insert(Target);
1180-
++It;
1181-
continue;
1182-
}
1183-
1184-
Modified = true;
1185-
BasicBlock *NewTarget =
1186-
BasicBlock::Create(F.getContext(), "new.sw.case", &F);
1187-
IRBuilder<> Builder(NewTarget);
1188-
Builder.CreateBr(Target);
1189-
SI->addCase(It->getCaseValue(), NewTarget);
1190-
It = SI->removeCase(It);
1191-
}
1192-
}
1193-
1194-
return Modified;
1195-
}
1196-
11971161
bool IsRequiredForPhiNode(BasicBlock *BB) {
11981162
for (BasicBlock *Successor : successors(BB)) {
11991163
for (PHINode &Phi : Successor->phis()) {
@@ -1321,11 +1285,6 @@ class SPIRVStructurizer : public FunctionPass {
13211285
virtual bool runOnFunction(Function &F) override {
13221286
bool Modified = false;
13231287

1324-
// In LLVM, Switches are allowed to have several cases branching to the same
1325-
// basic block. In SPIR-V, each target must be a distrinct block. This
1326-
// function makes sure each target is unique.
1327-
Modified |= splitSwitchCases(F);
1328-
13291288
// LLVM allows conditional branches to have both side jumping to the same
13301289
// block. It also allows switched to have a single default, or just one
13311290
// case. Cleaning this up now.

0 commit comments

Comments
 (0)