[PATCH][fold-const] Fix native_encode_real for HFmode constants

Kyrill Tkachov kyrylo.tkachov@foss.arm.com
Wed Oct 5 14:06:00 GMT 2016


Hi all,

I encountered a wrong-code issue with my WIP store merging pass when it was trying to encode HFmode constants.
I am using native_encode_real to write the constants to a byte array and it's breaking on big-endian.
For a 2-byte constant it ended up writing bytes at offsets 3 and 2 rather than 1 and 0.

The fix in this patch makes the logic in native_encode_real match the logic in native_interpret_real,
I just copied the logic across.

I don't have a testcase against clean trunk that demonstrates the issue but with my store merging patch
the testcase gcc.target/aarch64/advsimd-intrinsics/vldX.c starts failing without this patch because
adjacent 16-bit float constants are not being merged correctly.

Bootstrapped and tested on aarch64-none-linux-gnu.
As this patch only affects the big-endian code path I also tested it on aarch64_be-none-elf.

Ok for trunk? Do you think this needs to be backported?

Thanks,
Kyrill

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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fold-const-encode-real.patch
Type: text/x-patch
Size: 776 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20161005/e3b25876/attachment.bin>


More information about the Gcc-patches mailing list