From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7125 invoked by alias); 2 Sep 2004 08:19:05 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 7114 invoked from network); 2 Sep 2004 08:19:03 -0000 Received: from unknown (HELO lon-mail-2.gradwell.net) (193.111.201.126) by sourceware.org with SMTP; 2 Sep 2004 08:19:03 -0000 Received: (qmail 86178 invoked from network); 2 Sep 2004 08:19:02 -0000 Received: from digraph.polyomino.org.uk (postmaster%pop3.polyomino.org.uk@81.187.227.50) by lon-mail-2.gradwell.net with SMTP; 2 Sep 2004 08:19:02 -0000 Received: from jsm28 (helo=localhost) by digraph.polyomino.org.uk with local-esmtp (Exim 4.41) id 1C2moA-0006zz-Jb; Thu, 02 Sep 2004 08:19:02 +0000 Date: Thu, 02 Sep 2004 08:19:00 -0000 From: "Joseph S. Myers" X-X-Sender: jsm28@digraph.polyomino.org.uk To: Jie Zhang cc: gcc@gcc.gnu.org Subject: Re: A question about integer promotion in GCC In-Reply-To: <4136D20A.7010609@magima.com.cn> Message-ID: References: <4136D20A.7010609@magima.com.cn> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SW-Source: 2004-09/txt/msg00098.txt.bz2 On Thu, 2 Sep 2004, Jie Zhang wrote: > According to this, shouldn't it be: > > return (int)x << 8 | (int)x >> 8; > > Maybe it has no performance benefit. But it make the tree dump result > conforming to the standard and improve the readability of the final assembly > output when being compiled using -O2 option. How about your thoughts? The current function of tree dumps is for debugging the compiler, not as a representation of source. Various optimisations are performed on the trees generated, both in the process of generating them to avoid generating unnecessary garbage, and as part of fold(), before they get to the first tree dumps. (In this case, a right shift of a short can be represented directly on the short, whereas a left shift of a short cannot.) There is a mood towards doing less such optimisations at parse time (and generally reducing the front end / middle end overlap), in particular reducing parse-time folding to constant folding only and causing the remaining optimisations fold() does to be done later on GIMPLE. This is however a substantial task to do while being sure that each change is an incremental improvement that does not cause regressions, as every useful transformation fold() does would need implementing at a later stage, and the result would need careful checking to be sure that all such transformations had been properly implemented, before any can be removed from fold(). -- Joseph S. Myers http://www.srcf.ucam.org/~jsm28/gcc/ http://www.srcf.ucam.org/~jsm28/gcc/#c90status - status of C90 for GCC 3.5 jsm@polyomino.org.uk (personal mail) jsm28@gcc.gnu.org (Bugzilla assignments and CCs)