public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/32871]  New: Bad optimasation - Gcc is pushing to many registers
@ 2007-07-23 19:22 info at umfragen-service dot de
  2007-07-29 16:12 ` [Bug target/32871] " info at umfragen-service dot de
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: info at umfragen-service dot de @ 2007-07-23 19:22 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2010-01-29 17:02 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-23 19:22 [Bug c/32871] New: Bad optimasation - Gcc is pushing to many registers info at umfragen-service dot de
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

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).