@@ -1158,42 +1158,6 @@ class SPIRVStructurizer : public FunctionPass {
1158
1158
return Modified;
1159
1159
}
1160
1160
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
-
1197
1161
bool IsRequiredForPhiNode (BasicBlock *BB) {
1198
1162
for (BasicBlock *Successor : successors (BB)) {
1199
1163
for (PHINode &Phi : Successor->phis ()) {
@@ -1321,11 +1285,6 @@ class SPIRVStructurizer : public FunctionPass {
1321
1285
virtual bool runOnFunction (Function &F) override {
1322
1286
bool Modified = false ;
1323
1287
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
-
1329
1288
// LLVM allows conditional branches to have both side jumping to the same
1330
1289
// block. It also allows switched to have a single default, or just one
1331
1290
// case. Cleaning this up now.
0 commit comments