public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [SPARC] Fix miscompilation of Ada runtime in 64-bit mode
@ 2021-03-10 11:34 Eric Botcazou
  0 siblings, 0 replies; only message in thread
From: Eric Botcazou @ 2021-03-10 11:34 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 491 bytes --]

Returning a REGMODE_NATURAL_SIZE of 4 for DFmode in 64-bit mode is asking for 
trouble because sub-word SUBREGs are always treated differently than the 
others, in particular by the register allocator.

Bootstrapped/regtested on SPARC64/Linux and SPARC/Solaris, applied on the 
mainline.


2021-03-10  Eric Botcazou  <ebotcazou@adacore.com>

	* config/sparc/sparc.c (sparc_regmode_natural_size): Return 4 for
	float and vector integer modes only if the mode is not larger.

-- 
Eric Botcazou

[-- Attachment #2: p.diff --]
[-- Type: text/x-patch, Size: 1003 bytes --]

diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c
index f3557936114..f1504172022 100644
--- a/gcc/config/sparc/sparc.c
+++ b/gcc/config/sparc/sparc.c
@@ -13585,23 +13585,18 @@ sparc_expand_vcond (machine_mode mode, rtx *operands, int ccode, int fcode)
   emit_insn (gen_rtx_SET (operands[0], bshuf));
 }
 
-/* On sparc, any mode which naturally allocates into the float
+/* On the SPARC, any mode which naturally allocates into the single float
    registers should return 4 here.  */
 
 unsigned int
 sparc_regmode_natural_size (machine_mode mode)
 {
-  int size = UNITS_PER_WORD;
+  const enum mode_class cl = GET_MODE_CLASS (mode);
 
-  if (TARGET_ARCH64)
-    {
-      enum mode_class mclass = GET_MODE_CLASS (mode);
-
-      if (mclass == MODE_FLOAT || mclass == MODE_VECTOR_INT)
-	size = 4;
-    }
+  if ((cl == MODE_FLOAT || cl == MODE_VECTOR_INT) && GET_MODE_SIZE (mode) <= 4)
+    return 4;
 
-  return size;
+  return UNITS_PER_WORD;
 }
 
 /* Implement TARGET_HARD_REGNO_NREGS.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-03-10 11:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-10 11:34 [SPARC] Fix miscompilation of Ada runtime in 64-bit mode Eric Botcazou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).