From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16884 invoked by alias); 5 Jan 2013 15:35:34 -0000 Received: (qmail 16737 invoked by uid 22791); 5 Jan 2013 15:35:32 -0000 X-SWARE-Spam-Status: No, hits=-4.6 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,SARE_SUB_IMPROVE,TW_CP X-Spam-Check-By: sourceware.org Received: from mail-we0-f176.google.com (HELO mail-we0-f176.google.com) (74.125.82.176) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 05 Jan 2013 15:35:28 +0000 Received: by mail-we0-f176.google.com with SMTP id r5so8189539wey.21 for ; Sat, 05 Jan 2013 07:35:26 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.180.79.37 with SMTP id g5mr2396799wix.8.1357400126907; Sat, 05 Jan 2013 07:35:26 -0800 (PST) Received: by 10.194.179.130 with HTTP; Sat, 5 Jan 2013 07:35:26 -0800 (PST) In-Reply-To: References: Date: Sat, 05 Jan 2013 15:35:00 -0000 Message-ID: Subject: Re: [Patch, libfortran] Improve performance of byte swapped IO From: Richard Biener To: Andreas Schwab Cc: Janne Blomqvist , GCC Patches , Fortran List Content-Type: text/plain; charset=ISO-8859-1 X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2013-01/txt/msg00225.txt.bz2 On Fri, Jan 4, 2013 at 11:35 PM, Andreas Schwab wrote: > Janne Blomqvist 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."