public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jie Zhang <zhangjie@magima.com.cn>
To: "Joseph S. Myers" <jsm@polyomino.org.uk>
Cc: gcc@gcc.gnu.org
Subject: Re: A question about integer promotion in GCC
Date: Fri, 03 Sep 2004 08:33:00 -0000	[thread overview]
Message-ID: <41382C1E.5060507@magima.com.cn> (raw)
In-Reply-To: <Pine.LNX.4.61.0409020811190.26807@digraph.polyomino.org.uk>


Joseph S. Myers wrote:
> On Thu, 2 Sep 2004, Jie Zhang wrote:
>>According to this, shouldn't it be:
>>
>>    return (int)x << 8 | (int)x >> 8;
>>
> 
> 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.)
> 

I think optimizing "(int)x >> 8" to "(int)(x >> 8)" is not good, at least for RISCs, like MIPS. Now gcc (3.4.0) generates the following assembly with option -O0:

  lhu     $2,0($fp)
  sll     $2,$2,8
  lhu     $3,0($fp)
  srl     $3,$3,8
  andi    $3,$3,0xffff
  or      $2,$2,$3

IMO, the "andi" instruction is useless. I suspect it's due to this optimization. Without knowing it this assembly is confusing.

> There is a mood towards doing less such optimisations at parse time (and 

I like this idea. It will make both the structure of GCC and the -O0 assembly output more clear.


regards
-- 
Jie

  reply	other threads:[~2004-09-03  8:33 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-02  7:56 Jie Zhang
2004-09-02  8:09 ` Jie Zhang
2004-09-02  8:19 ` Joseph S. Myers
2004-09-03  8:33   ` Jie Zhang [this message]
2004-09-06  8:01   ` Nathan Sidwell
2004-09-06  8:43     ` Joseph S. Myers
2004-09-06  8:52       ` Nathan Sidwell
2004-09-06  9:01         ` Joseph S. Myers
2004-09-06  9:54           ` Nathan Sidwell
2004-09-06 11:59             ` Joseph S. Myers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=41382C1E.5060507@magima.com.cn \
    --to=zhangjie@magima.com.cn \
    --cc=gcc@gcc.gnu.org \
    --cc=jsm@polyomino.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).