diff --git a/src/coreclr/jit/lower.cpp b/src/coreclr/jit/lower.cpp index b122b8de775259..2cd5507940790b 100644 --- a/src/coreclr/jit/lower.cpp +++ b/src/coreclr/jit/lower.cpp @@ -5859,6 +5859,17 @@ void Lowering::LowerRetStruct(GenTreeUnOp* ret) else { assert(varTypeUsesIntReg(nativeReturnType)); + // ZeroObj assertion propagation can create an INT zero for a wider + // (e.g. LONG) integer struct return. Retype it to the native return type + // so that targets with a typed value stack (Wasm) emit e.g. an i64.const + // rather than an i32.const. Mirrors the float/double case above. +#if defined(TARGET_WASM) + if (genActualType(retVal) != genActualType(nativeReturnType)) + { + assert(retVal->IsIntegralConst(0)); + retVal->BashToZeroConst(nativeReturnType); + } +#endif // defined(TARGET_WASM) } break; }