diff --git a/src/coreclr/jit/codegenwasm.cpp b/src/coreclr/jit/codegenwasm.cpp index e8f750d8f9e9dd..af5475d0ff3148 100644 --- a/src/coreclr/jit/codegenwasm.cpp +++ b/src/coreclr/jit/codegenwasm.cpp @@ -1737,13 +1737,12 @@ void CodeGen::genCodeForShift(GenTree* tree) GenTreeOp* treeNode = tree->AsOp(); genConsumeOperands(treeNode); - // TODO-WASM: Zero-extend the 2nd operand for shifts and rotates as needed when the 1st and 2nd operand are - // different types. The shift operand width in IR is always TYP_INT; the WASM operations have the same widths - // for both the shift and shiftee. So the shift may need to be extended (zero-extended) for TYP_LONG. - + // The shift operand width in IR is always int or small int, so the operand's actual type should be TYP_INT. + // However, the WASM operations have the same widths for both the shift and shiftee so + // the shift width may need to be zero-extended if the shift result type is TYP_LONG. if (treeNode->TypeIs(TYP_LONG)) { - assert(treeNode->gtGetOp2()->TypeIs(TYP_INT)); + assert(genActualType(treeNode->gtGetOp2()->TypeGet()) == TYP_INT); // Zero-extend the shift amount to 64 bits for long shifts/rotates. // Wasteful if the amount was a constant, perhaps we should contain it if so. GetEmitter()->emitIns(INS_i64_extend_u_i32);