From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9212 invoked by alias); 2 Nov 2012 17:46:24 -0000 Received: (qmail 9134 invoked by uid 48); 2 Nov 2012 17:45:55 -0000 From: "ebotcazou at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/55177] missed optimizations with __builtin_bswap Date: Fri, 02 Nov 2012 17:46:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: ebotcazou at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: ebotcazou at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Status AssignedTo Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 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 X-SW-Source: 2012-11/txt/msg00170.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55177 Eric Botcazou changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED AssignedTo|unassigned at gcc dot |ebotcazou at gcc dot |gnu.org |gnu.org --- Comment #4 from Eric Botcazou 2012-11-02 17:45:54 UTC --- > The first example isn't *that* dumb, as a cut-down test case of real code > which may look more complex in reality. OK, and I can indeed think of some usage patterns in real life. > If the real code really *is* as simple as my test case, you're right that > perhaps we *could* optimise it ourselves by eschewing the normal accessor > macros for explicit-endian values, and manually byteswapping the constant > instead. > > But really, we shouldn't *have* to. The compiler can see what's happening, and > it can deal with it a whole lot better than we can, especially when it comes > to loads and stores. Another category would be comparisons then: int compare1 (int x) { return __builtin_bswap32 (x) == 0xdeadbeef; } int compare2 (int x, int y) { return __builtin_bswap32 (x) == __builtin_bswap32 (y); } Will have a look shortly.