From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21042 invoked by alias); 23 Jan 2015 14:08:58 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 20919 invoked by uid 48); 23 Jan 2015 14:08:52 -0000 From: "dwmw2 at infradead dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/55177] missed optimizations with __builtin_bswap Date: Fri, 23 Jan 2015 14:08:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 4.7.2 X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: dwmw2 at infradead dot org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: pinskia at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-01/txt/msg02568.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55177 --- Comment #17 from David Woodhouse --- Er, yes. Sorry, I originally tried it with uint16_t but it wasn't even using movbe for the pointer_abuse() function then, so I made it 32-bit instead. Badly. Come to think of it, the lack of movbe in the 16-bit pointer_abuse() case is potentially another bug worth fixing. Here's the corrected test case. /* gcc -march=atom -O2 -c load_be.c -Wstrict-aliasing -o- -S */ struct pkt { unsigned char data[10]; }; unsigned or(struct pkt *p) { return (p->data[0] << 24) | (p->data[1] << 16) | (p->data[2] << 8) | p->data[3]; } unsigned add(struct pkt *p) { return (p->data[0] << 24) + (p->data[1] << 16) + (p->data[2] << 8) + p->data[3]; } unsigned pointer_abuse(struct pkt *p) { return __builtin_bswap16(*(unsigned short *)p->data); }