[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
This commit is contained in:
Kyrylo Tkachov 2016-10-05 14:57:14 +00:00 committed by Kyrylo Tkachov
parent aaae096a1a
commit 37a1d58a10
2 changed files with 15 additions and 1 deletions

View File

@ -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> 2016-10-05 Wilco Dijkstra <wdijkstr@arm.com>
* builtins.c (fold_builtin_strchr): Remove function. * builtins.c (fold_builtin_strchr): Remove function.

View File

@ -7142,7 +7142,16 @@ native_encode_real (const_tree expr, unsigned char *ptr, int len, int off)
offset += byte % UNITS_PER_WORD; offset += byte % UNITS_PER_WORD;
} }
else 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); offset = offset + ((bitpos / BITS_PER_UNIT) & ~3);
if (offset >= off if (offset >= off
&& offset - off < len) && offset - off < len)