public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/38209]  New: [avr] branch optimisation generates worse code
@ 2008-11-21  6:06 k dot kosciuszkiewicz+gcc at gmail dot com
  2008-11-21  6:07 ` [Bug c/38209] " k dot kosciuszkiewicz+gcc at gmail dot com
  2008-11-23 18:57 ` [Bug middle-end/38209] " pinskia at gcc dot gnu dot org
  0 siblings, 2 replies; 3+ messages in thread
From: k dot kosciuszkiewicz+gcc at gmail dot com @ 2008-11-21  6:06 UTC (permalink / raw)
  To: gcc-bugs

Test code:

register unsigned char val asm("r4");

void negate(void)
{
    if (val)
        val = ~val;
    else
        val = ~val;
}

Code generated with -Os

.global negate
        .type   negate, @function
negate:
/* prologue: function */
/* frame size = 0 */
        tst r4
        breq .L2
        com r4
        ret
.L2:
        clr r4
        dec r4
        ret
        .size   negate, .-negate

In the "else" branch gcc knows that r4 is zero, and that it should change to
0xff - taking this approach generates longer code than in the first branch.

The same applies when operations like !, ++, -- are used.


-- 
           Summary: [avr] branch optimisation generates worse code
           Product: gcc
           Version: 4.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: k dot kosciuszkiewicz+gcc at gmail dot com
 GCC build triplet: i386-linux-gnu
  GCC host triplet: i386-linux-gnu
GCC target triplet: avr-*-*


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


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

end of thread, other threads:[~2008-11-23 18:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-21  6:06 [Bug c/38209] New: [avr] branch optimisation generates worse code k dot kosciuszkiewicz+gcc at gmail dot com
2008-11-21  6:07 ` [Bug c/38209] " k dot kosciuszkiewicz+gcc at gmail dot com
2008-11-23 18:57 ` [Bug middle-end/38209] " pinskia at gcc dot gnu dot org

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