[RISC-V] Put scalar stack args with sign extension (#97662) (#392) accepted/tizen/unified/x/20240214.051929
author이형주/MDE Lab(SR)/삼성전자 <leee.lee@samsung.com>
Thu, 8 Feb 2024 07:45:20 +0000 (16:45 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Thu, 8 Feb 2024 07:45:20 +0000 (16:45 +0900)
Co-authored-by: t-mustafin <66252296+t-mustafin@users.noreply.github.com>
src/coreclr/jit/codegenriscv64.cpp

index 4aec678..50b4fe6 100644 (file)
@@ -5001,6 +5001,14 @@ void CodeGen::genPutArgStk(GenTreePutArgStk* treeNode)
         instruction storeIns  = ins_Store(slotType);
         emitAttr    storeAttr = emitTypeSize(slotType);
 
+        // When passed in registers or on the stack, integer scalars narrower than XLEN bits
+        // are widened according to the sign of their type up to 32 bits, then sign-extended to XLEN bits.
+        if (EA_SIZE(storeAttr) < EA_PTRSIZE && varTypeUsesIntReg(slotType))
+        {
+            storeAttr = EA_PTRSIZE;
+            storeIns  = INS_sd;
+        }
+
         // If it is contained then source must be the integer constant zero
         if (source->isContained())
         {