* How to force GNU CC use "inc" for `++' operator?
@ 2005-01-08 5:59 Dmitry K.
0 siblings, 0 replies; only message in thread
From: Dmitry K. @ 2005-01-08 5:59 UTC (permalink / raw)
To: gcc-help
Hi.
In the next example GCC differently processes two alike lines, containing
increment of `c':
extern int foo1 (int,int);
int foo (int x, int y)
{
unsigned char c= 0;
if (foo1(x,y)) c++;
if (foo1(x,y)) c++;
return c;
}
`inc r15' is used at the second increment. But at first -- pair operations:
`ldi' and `mov'. This occupies two words instead of one and is executed twice
longer:
foo:
/* prologue: frame size=0 */
push r15
push r16
push r17
push r28
push r29
/* prologue end (size=5) */
movw r16,r24
movw r28,r22
clr r15
rcall foo1
or r24,r25
breq .L2
ldi r24,lo8(1) /**************/
mov r15,r24 /**************/
.L2:
movw r22,r28
movw r24,r16
rcall foo1
or r24,r25
breq .L3
inc r15 /**************/
.L3:
mov r24,r15
clr r25
/* epilogue: frame size=0 */
pop r29
pop r28
pop r17
pop r16
pop r15
ret
Certainly, 4% is rubbish. But this example is an extract from real program,
where lack of the free register gave considerable decline.
Was used: gcc 3.4.3, --target=avr, -Os, -mmcu=atmega8
Thanks in advance.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2005-01-08 5:59 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-08 5:59 How to force GNU CC use "inc" for `++' operator? Dmitry K.
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).