From 27fc08c3b6397fa1588d69f622d7f057024be501 Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Tue, 23 May 2023 11:20:35 +0200 Subject: [PATCH] JIT: Use unsigned native return types for small structs Prefer the return type to be unsigned when small structs are returned in registers. This causes the backend to use zero extension instead of sign extension in a few cases, which has a smaller encoding on xarch. --- src/coreclr/jit/compiler.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/coreclr/jit/compiler.cpp b/src/coreclr/jit/compiler.cpp index 6a19d89253d40f..688a4b61b87ea2 100644 --- a/src/coreclr/jit/compiler.cpp +++ b/src/coreclr/jit/compiler.cpp @@ -529,11 +529,11 @@ var_types Compiler::getPrimitiveTypeForStruct(unsigned structSize, CORINFO_CLASS switch (structSize) { case 1: - useType = TYP_BYTE; + useType = TYP_UBYTE; break; case 2: - useType = TYP_SHORT; + useType = TYP_USHORT; break; #if !defined(TARGET_XARCH) || defined(UNIX_AMD64_ABI)