How to force GNU CC use "inc" for `++' operator?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux