aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYvan Roux <yvan.roux@linaro.org>2016-10-15 21:51:57 +0200
committerYvan Roux <yvan.roux@linaro.org>2016-10-15 21:51:57 +0200
commitfaa305b774c43035fa1f34aadd6dfb803105dfa2 (patch)
treec04047502510aa826644fee73c33fad79e61f6ca
parent266614143ba16d6b228ab1e8359963ce86c41416 (diff)
gcc/
Backport from trunk r240791. 2016-10-05 Kyrylo Tkachov <kyrylo.tkachov@arm.com> * fold-const.c (native_encode_real): Fix logic for selecting offset to write to when BYTES_BIG_ENDIAN. Change-Id: I0ce72bead9880c0064f34a629499271b9337cdf8
-rw-r--r--gcc/fold-const.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index ee7d4f58ba7..bf3ba487871 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -7215,7 +7215,16 @@ native_encode_real (const_tree expr, unsigned char *ptr, int len, int off)
offset += byte % UNITS_PER_WORD;
}
else
- offset = BYTES_BIG_ENDIAN ? 3 - byte : byte;
+ {
+ offset = byte;
+ if (BYTES_BIG_ENDIAN)
+ {
+ /* Reverse bytes within each long, or within the entire float
+ if it's smaller than a long (for HFmode). */
+ offset = MIN (3, total_bytes - 1) - offset;
+ gcc_assert (offset >= 0);
+ }
+ }
offset = offset + ((bitpos / BITS_PER_UNIT) & ~3);
if (offset >= off
&& offset - off < len)