File tree Expand file tree Collapse file tree 4 files changed +16
-14
lines changed
Expand file tree Collapse file tree 4 files changed +16
-14
lines changed Original file line number Diff line number Diff line change @@ -337,14 +337,10 @@ void CodeGen::genTableBasedSwitch(GenTree* treeNode)
337337 BBswtDesc* const desc = block->GetSwitchTargets ();
338338 unsigned const caseCount = desc->GetCaseCount ();
339339
340- // TODO-WASM: update lowering not to peel off the default
340+ // We don't expect degenerate or default-less switches
341341 //
342- assert (!desc->HasDefaultCase ());
343-
344- if (caseCount == 0 )
345- {
346- return ;
347- }
342+ assert (caseCount > 0 );
343+ assert (desc->HasDefaultCase ());
348344
349345 GetEmitter ()->emitIns_I (INS_br_table, EA_4BYTE, caseCount);
350346
Original file line number Diff line number Diff line change @@ -1657,7 +1657,11 @@ bool Compiler::fgOptimizeSwitchBranches(BasicBlock* block)
16571657 blockRange = &LIR::AsRange (block);
16581658 switchTree = blockRange->LastNode ();
16591659
1660+ #ifdef TARGET_WASM
1661+ assert (switchTree->OperIs (GT_SWITCH));
1662+ #else
16601663 assert (switchTree->OperIs (GT_SWITCH_TABLE));
1664+ #endif
16611665 }
16621666 else
16631667 {
Original file line number Diff line number Diff line change @@ -1144,7 +1144,6 @@ PhaseStatus Compiler::fgWasmControlFlow()
11441144 }
11451145
11461146 // Branch to next needs no block, unless this is a switch
1147- // (eventually when we leave the default on the switch we can remove this).
11481147 //
11491148 if ((succNum == (cursor + 1 )) && !block->KindIs (BBJ_SWITCH))
11501149 {
@@ -1623,13 +1622,10 @@ void Compiler::fgDumpWasmControlFlow()
16231622 BBswtDesc* const desc = block->GetSwitchTargets ();
16241623 unsigned const caseCount = desc->GetCaseCount ();
16251624
1626- // BR_TABLE supports a default case, so we need to ensure
1627- // that wasm lower does not remove it.
1625+ // BR_TABLE supports a default case.
1626+ // Wasm lower should not remove it.
16281627 //
1629- // For now, we expect non-wasm lower has made the default case check explicit
1630- // and so our BR_TABLE emission is deficient.
1631- //
1632- assert (!desc->HasDefaultCase ());
1628+ assert (desc->HasDefaultCase ());
16331629
16341630 if (caseCount == 0 )
16351631 {
Original file line number Diff line number Diff line change @@ -891,6 +891,12 @@ GenTree* Lowering::LowerSwitch(GenTree* node)
891891
892892 noway_assert (jumpCnt >= 2 );
893893
894+ #ifdef TARGET_WASM
895+ // Wasm's br_table maps exactly to GT_SWITCH
896+ //
897+ return node->gtNext ;
898+ #endif // TARGET_WASM
899+
894900 // Spill the argument to the switch node into a local so that it can be used later.
895901 LIR::Use use (switchBBRange, &(node->AsOp ()->gtOp1 ), node);
896902 ReplaceWithLclVar (use);
You can’t perform that action at this time.
0 commit comments