On Wed, Oct 5, 2016 at 4:06 PM, Kyrill Tkachov <kyrylo.tkac...@foss.arm.com> wrote: > 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
Might be sth simple as unsigned short foo (void) { unsigned short bar; typedef HFmode alias_HF __attribute__((may_alias)); *(ailas_HFmode *)bar = HFmode constant; return bar; } which should get a bogus integer representation from FRE. > 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.tkac...@arm.com> > > * fold-const.c (native_encode_real): Fix logic for selecting offset > to write to when BYTES_BIG_ENDIAN.