diff options
author | ktkachov <ktkachov@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-10-05 14:57:14 +0000 |
---|---|---|
committer | ktkachov <ktkachov@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-10-05 14:57:14 +0000 |
commit | 4ef28321d4c7c8413addd37970f80b63c1d6c1b0 (patch) | |
tree | 6e74c991466d293548ba5786c62793824add2229 /gcc/fold-const.c | |
parent | 59deb1a22e04a8a6289abbf21f853417726a5d3b (diff) | |
download | gcc-4ef28321d4c7c8413addd37970f80b63c1d6c1b0.tar.gz |
[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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@240791 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index a6b7ec7dfec..65c75f63931 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) |