]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
x86: Remove DI_REG/SI_REG from x86_64_int_return_registers
authorH.J. Lu <hjl.tools@gmail.com>
Wed, 15 Apr 2026 05:43:08 +0000 (13:43 +0800)
committerH.J. Lu <hjl.tools@gmail.com>
Thu, 30 Apr 2026 21:25:04 +0000 (05:25 +0800)
Since only AX/DX register pair and XMM0/XMM1 register pair are used for
function return values in 64-bit mode, remove DI_REG and SI_REG registers
from x86_64_int_return_registers and limit the number of registers used
in return values to 2 in 64-bit mode.

Tested on Linux/x86-64 and Linux/i686.

PR target/124878
* config/i386/i386.cc (x86_64_int_return_registers): Remove
DI_REG and SI_REG.
(ix86_function_value_regno_p): Remove DI_REG and SI_REG cases.
(function_value_64): Replace X86_64_REGPARM_MAX and
X86_64_SSE_REGPARM_MAX with X86_64_MAX_RETURN_NREGS and
X86_64_MAX_SSE_RETURN_NREGS for the number of registers used
in return values.
* config/i386/i386.h (X86_64_MAX_RETURN_NREGS): New.  Defined
to 2.
(X86_64_MAX_SSE_RETURN_NREGS): Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
gcc/config/i386/i386.cc
gcc/config/i386/i386.h

index c11da783c8cfb22c044e7f2555775e22cfdc3a6b..15c2d631635b0d32ee58ebda6e0f175664168b97 100644 (file)
@@ -343,9 +343,9 @@ static int const x86_64_preserve_none_int_parameter_registers[6] =
   R12_REG, R13_REG, R14_REG, R15_REG, DI_REG, SI_REG
 };
 
-static int const x86_64_int_return_registers[4] =
+static int const x86_64_int_return_registers[2] =
 {
-  AX_REG, DX_REG, DI_REG, SI_REG
+  AX_REG, DX_REG
 };
 
 /* Define the structure for the machine field in struct function.  */
@@ -3870,9 +3870,6 @@ ix86_function_value_regno_p (const unsigned int regno)
       return true;
     case DX_REG:
       return (!TARGET_64BIT || ix86_cfun_abi () != MS_ABI);
-    case DI_REG:
-    case SI_REG:
-      return TARGET_64BIT && ix86_cfun_abi () != MS_ABI;
 
       /* Complex values are returned in %st(0)/%st(1) pair.  */
     case ST0_REG:
@@ -4310,7 +4307,8 @@ function_value_64 (machine_mode orig_mode, machine_mode mode,
     }
 
   ret = construct_container (mode, orig_mode, valtype, true,
-                            X86_64_REGPARM_MAX, X86_64_SSE_REGPARM_MAX,
+                            X86_64_MAX_RETURN_NREGS,
+                            X86_64_MAX_SSE_RETURN_NREGS,
                             x86_64_int_return_registers, 0);
 
   /* For zero sized structures, construct_container returns NULL, but we
index 80dafd1f9ae96282ab423682c853dc674f2f6273..21108f39938444b2bea2d18eaf0eba475e506bee 100644 (file)
@@ -1878,6 +1878,11 @@ typedef struct ix86_args {
 #define X86_64_REGPARM_MAX 6
 #define X86_64_MS_REGPARM_MAX 4
 
+/* Maximum numbers of registers used in return values according to x86-64
+   psABI.  */
+#define X86_64_MAX_RETURN_NREGS 2
+#define X86_64_MAX_SSE_RETURN_NREGS 2
+
 #define X86_32_REGPARM_MAX 3
 
 #define REGPARM_MAX                                                    \