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
* [Bug c/38209] [avr] branch optimisation generates worse code
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 ` k dot kosciuszkiewicz+gcc at gmail dot com
2008-11-23 18:57 ` [Bug middle-end/38209] " pinskia at gcc dot gnu dot org
1 sibling, 0 replies; 3+ messages in thread
From: k dot kosciuszkiewicz+gcc at gmail dot com @ 2008-11-21 6:07 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from k dot kosciuszkiewicz+gcc at gmail dot com 2008-11-21 06:05 -------
Created an attachment (id=16730)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=16730&action=view)
Test case.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38209
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug middle-end/38209] branch optimisation generates worse code
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 ` pinskia at gcc dot gnu dot org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-11-23 18:57 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from pinskia at gcc dot gnu dot org 2008-11-23 18:55 -------
This happens on i386-darwin also (-m64 -O2 -fomit-frame-pointer):
movl %edi, %edx
testb %dil, %dil
movl $-1, %eax
notl %edx
cmovne %edx, %eax
Using the following source:
unsigned char negate(unsigned char val)
{
if (val)
val = ~val;
else
val = ~val;
return val;
}
We should be able to just do ~val but this comes down to hoisting before
applying VRP/DOM.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
GCC build triplet|i386-linux-gnu |
GCC host triplet|i386-linux-gnu |
GCC target triplet|avr-*-* |
Last reconfirmed|0000-00-00 00:00:00 |2008-11-23 18:55:59
date| |
Summary|[avr] branch optimisation |branch optimisation
|generates worse code |generates worse code
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).