public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "info at umfragen-service dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/32871]  New: Bad optimasation - Gcc is pushing to many registers
Date: Mon, 23 Jul 2007 19:22:00 -0000	[thread overview]
Message-ID: <bug-32871-14897@http.gcc.gnu.org/bugzilla/> (raw)

Let's look at this:

long foo(long a, long b, long c, uint8_t d){
  if(d){
    return a+b;
  }else{
    return a-c;
  }
}

The listing reports this:
long foo(long a, long b, long c, uint8_t d){
  4e:   cf 92          push   r12 ;All this registers are pushed
  50:   ef 92          push   r14 ;despite it's unessecary
  52:   ff 92          push   r15 ;
  54:   0f 93          push   r16
  56:   1f 93          push   r17
  if(d){
  58:   cc 20          and   r12, r12
  5a:   29 f0          breq   .+10        ; 0x66 <foo+0x18>
    return a+b;
  5c:   62 0f          add   r22, r18
  5e:   73 1f          adc   r23, r19
  60:   84 1f          adc   r24, r20
  62:   95 1f          adc   r25, r21
  64:   04 c0          rjmp   .+8         ; 0x6e <foo+0x20>
  }else{
    return a-c;
  66:   6e 19          sub   r22, r14
  68:   7f 09          sbc   r23, r15
  6a:   80 0b          sbc   r24, r16
  6c:   91 0b          sbc   r25, r17
  6e:   1f 91          pop   r17 ;And they are getting restored
  70:   0f 91          pop   r16 ;despite they are not changed.
  72:   ff 90          pop   r15
  74:   ef 90          pop   r14
  76:   cf 90          pop   r12
  78:   08 95          ret

During all operation in the low register (r3-r17) are always zero, and they are
never changed in the hole file and even not in the function itself. So it's
useless to push and pop them, we're only loosing time, space and ram.

Please excuse my bad bug-reporting-style. This is my first report. For further
explainaition I can recomment you the german site, where this problem is beeing
discussed.

http://www.roboternetz.de/phpBB2/viewtopic.php?p=300953

I hope you can fix this.

Michael


-- 
           Summary: Bad optimasation - Gcc is pushing to many registers
           Product: gcc
           Version: 4.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: info at umfragen-service dot de
 GCC build triplet: Linux - Slax
  GCC host triplet: Linux - Slax
GCC target triplet: avr


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32871


             reply	other threads:[~2007-07-23 19:22 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-23 19:22 info at umfragen-service dot de [this message]
2007-07-29 16:12 ` [Bug target/32871] " info at umfragen-service dot de
2008-02-19  2:45 ` [Bug target/32871] [avr] Bad optimisation - gcc is pushing too " eric dot weddington at atmel dot com
2008-03-02 17:22 ` hutchinsonandy at aim dot com
2008-03-02 23:33 ` hutchinsonandy at aim dot com
2008-04-23 22:55 ` eric dot weddington at atmel dot com
2008-04-28  0:59 ` hutchinsonandy at aim dot com
2008-04-28  0:59 ` hutchinsonandy at aim dot com
2008-05-05  1:16 ` hutchinsonandy at gcc dot gnu dot org
2008-05-28  0:46 ` hutchinsonandy at gcc dot gnu dot org
2010-01-29 17:02 ` eric dot weddington at atmel dot com

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=bug-32871-14897@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).