diff --git a/src/coreclr/jit/codegenwasm.cpp b/src/coreclr/jit/codegenwasm.cpp index 83a5412fd3a52f..bb65235083748f 100644 --- a/src/coreclr/jit/codegenwasm.cpp +++ b/src/coreclr/jit/codegenwasm.cpp @@ -566,8 +566,14 @@ void CodeGen::genTableBasedSwitch(GenTree* treeNode) assert(caseCount > 0); assert(desc->HasDefaultCase()); - GetEmitter()->emitIns_I(INS_br_table, EA_4BYTE, caseCount); + // br_table list (labelidx*) labelidx + // list is prefixed with length, which is caseCount - 1 + // + GetEmitter()->emitIns_I(INS_br_table, EA_4BYTE, caseCount - 1); + // Emit the list case targets, then default case target + // (which is always the last case in the desc). + // for (unsigned caseNum = 0; caseNum < caseCount; caseNum++) { BasicBlock* const caseTarget = desc->GetCase(caseNum)->getDestinationBlock();