diff mbox

][AArch64][PATCH] Fix big endian float immediate moves.

Message ID 20170801150510.GA11610@arm.com
State New
Headers show

Commit Message

Tamar Christina Aug. 1, 2017, 3:05 p.m. UTC
Hi All,

real_to_target seems to return the order of the elements in the array
differently depending on the endiannes. This undoes the endianness when
combining the values back to a HOST_WIDE_INT.

Regtested on aach64-none-linux-gnu and aarch64_be-none-linux-gnu and no issues.

Thanks,
Tamar


gcc/
2017-08-01  Tamar Christina  <tamar.christina@arm.com>

	* config/aarch64/aarch64.c (aarch64_reinterpret_float_as_int):
	Correct endianness.

--

Comments

James Greenhalgh Aug. 2, 2017, 8:28 a.m. UTC | #1
On Tue, Aug 01, 2017 at 04:05:13PM +0100, Tamar Christina wrote:
> Hi All,
> 
> real_to_target seems to return the order of the elements in the array
> differently depending on the endiannes. This undoes the endianness when
> combining the values back to a HOST_WIDE_INT.
> 
> Regtested on aach64-none-linux-gnu and aarch64_be-none-linux-gnu and no issues.

OK. But...

> +      ival |= (zext_hwi (res[1-order], 32) << 32);

Spaces either side of the '-' please.

Cheers,
James
diff mbox

Patch

diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 5a2ad7e9156a6f0389c09470cf1414bff45d8099..84e0c937665a02f06e15ddf334978fe2a0da565f 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -4733,9 +4733,14 @@  aarch64_reinterpret_float_as_int (rtx value, unsigned HOST_WIDE_INT *intval)
 		  CONST_DOUBLE_REAL_VALUE (value),
 		  REAL_MODE_FORMAT (mode));
 
-  ival = zext_hwi (res[0], 32);
-  if (GET_MODE_BITSIZE (mode) == GET_MODE_BITSIZE (DFmode))
-    ival |= (zext_hwi (res[1], 32) << 32);
+  if (mode == DFmode)
+    {
+      int order = BYTES_BIG_ENDIAN ? 1 : 0;
+      ival = zext_hwi (res[order], 32);
+      ival |= (zext_hwi (res[1-order], 32) << 32);
+    }
+  else
+      ival = zext_hwi (res[0], 32);
 
   *intval = ival;
   return true;