Skip to content

Commit 8972410

Browse files
authored
JIT: Detect degenerate switches in switch recognition (#122865)
1 parent 7b90979 commit 8972410

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/coreclr/jit/switchrecognition.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,8 @@ bool Compiler::optSwitchConvert(BasicBlock* firstBlock,
473473
FlowEdge** const jmpTab =
474474
new (this, CMK_FlowEdge) FlowEdge*[2 + jumpCount + 1 /* true/false edges | cases | default case */];
475475

476-
firstBlock->SetSwitch(new (this, CMK_BasicBlock) BBswtDesc(jmpTab, 2, jmpTab + 2, jumpCount + 1, true));
476+
unsigned numSuccs = blockIfTrue == blockIfFalse ? 1 : 2;
477+
firstBlock->SetSwitch(new (this, CMK_BasicBlock) BBswtDesc(jmpTab, numSuccs, jmpTab + 2, jumpCount + 1, true));
477478
firstBlock->bbCodeOffsEnd = lastBlock->bbCodeOffsEnd;
478479
firstBlock->lastStmt()->GetRootNode()->ChangeOper(GT_SWITCH);
479480

0 commit comments

Comments
 (0)