aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyrylo Tkachov <kyrylo.tkachov@arm.com>2016-10-05 14:57:14 +0000
committerKyrylo Tkachov <ktkachov@gcc.gnu.org>2016-10-05 14:57:14 +0000
commit37a1d58a10eb8b176c8fac2a25bd8ca8cba0a91e (patch)
tree6e74c991466d293548ba5786c62793824add2229
parentaaae096a1ad2bfc378769eb7f73892813049a533 (diff)
downloadgcc-37a1d58a10eb8b176c8fac2a25bd8ca8cba0a91e.zip
gcc-37a1d58a10eb8b176c8fac2a25bd8ca8cba0a91e.tar.gz
gcc-37a1d58a10eb8b176c8fac2a25bd8ca8cba0a91e.tar.bz2
[fold-const] Fix native_encode_real for HFmode constants
* fold-const.c (native_encode_real): Fix logic for selecting offset to write to when BYTES_BIG_ENDIAN. From-SVN: r240791
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/fold-const.c11
2 files changed, 15 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 81e4235..6b4dc9c 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+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.
+
2016-10-05 Wilco Dijkstra <wdijkstr@arm.com>
* builtins.c (fold_builtin_strchr): Remove function.
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index a6b7ec7d..65c75f6 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -7142,7 +7142,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)