[Patch, libfortran] Improve performance of byte swapped IO
Richard Biener
richard.guenther@gmail.com
Sat Jan 5 15:35:00 GMT 2013
On Fri, Jan 4, 2013 at 11:35 PM, Andreas Schwab <schwab@linux-m68k.org> wrote:
> Janne Blomqvist <blomqvist.janne@gmail.com> writes:
>
>> diff --git a/libgfortran/io/file_pos.c b/libgfortran/io/file_pos.c
>> index c8ecc3a..bf2250a 100644
>> --- a/libgfortran/io/file_pos.c
>> +++ b/libgfortran/io/file_pos.c
>> @@ -140,15 +140,21 @@ unformatted_backspace (st_parameter_filepos *fpp, gfc_unit *u)
>> }
>> else
>> {
>> + uint32_t u32;
>> + uint64_t u64;
>> switch (length)
>> {
>> case sizeof(GFC_INTEGER_4):
>> - reverse_memcpy (&m4, p, sizeof (m4));
>> + memcpy (&u32, p, sizeof (u32));
>> + u32 = __builtin_bswap32 (u32);
>> + m4 = *(GFC_INTEGER_4*)&u32;
>
> Isn't that an aliasing violation?
It looks like one. Why not simply do
m4 = (GFC_INTEGER_4) u32;
? I suppose GFC_INTEGER_4 is always the same size as uint32_t but signed?
Richard.
>
> Andreas.
>
> --
> Andreas Schwab, schwab@linux-m68k.org
> GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
> "And now for something completely different."
More information about the Fortran
mailing list