From 32966dbe3d5246c82a5c418d626d0a3c78046110 Mon Sep 17 00:00:00 2001 From: adamperlin Date: Fri, 12 Jun 2026 11:28:27 -0700 Subject: [PATCH 1/2] JIT: Fix incorrect assert for shift amount type in codegenwasm.cpp --- src/coreclr/jit/codegenwasm.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/jit/codegenwasm.cpp b/src/coreclr/jit/codegenwasm.cpp index e8f750d8f9e9dd..0652488a4781c3 100644 --- a/src/coreclr/jit/codegenwasm.cpp +++ b/src/coreclr/jit/codegenwasm.cpp @@ -1743,7 +1743,7 @@ void CodeGen::genCodeForShift(GenTree* tree) 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); From 44373f5bb3347874455616b3f3a82bcf375bc9a3 Mon Sep 17 00:00:00 2001 From: adamperlin Date: Fri, 12 Jun 2026 12:45:01 -0700 Subject: [PATCH 2/2] Update comment in genCodeForShift --- src/coreclr/jit/codegenwasm.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/coreclr/jit/codegenwasm.cpp b/src/coreclr/jit/codegenwasm.cpp index 0652488a4781c3..af5475d0ff3148 100644 --- a/src/coreclr/jit/codegenwasm.cpp +++ b/src/coreclr/jit/codegenwasm.cpp @@ -1737,10 +1737,9 @@ 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(genActualType(treeNode->gtGetOp2()->TypeGet()) == TYP_INT);