This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: A question about integer promotion in GCC
- From: "Joseph S. Myers" <jsm at polyomino dot org dot uk>
- To: Jie Zhang <zhangjie at magima dot com dot cn>
- Cc: gcc at gcc dot gnu dot org
- Date: Thu, 2 Sep 2004 08:19:02 +0000 (UTC)
- Subject: Re: A question about integer promotion in GCC
- References: <4136D20A.7010609@magima.com.cn>
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)