Dmitry,

I posted a suggestion for optimization a week ago.
This seems to be a good candidate for the peephole optimizer.
See original post below.

Ralf

-----------------------


"Ralf Guetlein" <ralf.guetl...@web.de> schrieb im Newsbeitrag
news:bh819s$5v...@sea.gmane.org...
> Hi all,
>
> as you see in the disassembly listing below, there is
> a small lack of optimisation:
>
> The compiler refuses to use autoincrement when moving
> byte blocks. With integer values it works ok.
>
> move bytes:
>    6: ee 4f 00 00  mov.b @r15, 0(r14) ;
>    a: 1f 53        inc r15  ;
>    c: 1e 53        inc r14  ;
>
> move integers:
>   1c: be 4f 00 00  mov @r15+, 0(r14) ;
>   20: 2e 53        incd r14  ;
>
> I assume this can be fixed easily, but I'm not too much
> involved in gcc programming now, so I ask for your support.
>
> Regards,
> Ralf
>
> See the whole listing below:
>
>
>
> test.o:     file format elf32-msp430
>
> Disassembly of section .text:
>
> 00000000 <copybytes>:
> void copybytes(char *src, char *dst, int len)
> {
>   while (len--)
>    0: 3d 53        add #-1, r13 ;r3 As==11
>    2: 3d 93        cmp #-1, r13 ;r3 As==11
>    4: 07 24        jz $+16      ;abs 0x14
>     *dst++ = *src++;
>    6: ee 4f 00 00  mov.b @r15, 0(r14) ;
>    a: 1f 53        inc r15  ;
>    c: 1e 53        inc r14  ;
>    e: 3d 53        add #-1, r13 ;r3 As==11
>   10: 3d 93        cmp #-1, r13 ;r3 As==11
>   12: f9 23        jnz $-12      ;abs 0x6
> }
>   14: 30 41        ret
>
> 00000016 <copywords>:
>
>
> void copywords(int *src, int *dst, int len)
> {
>   while (len--)
>   16: 3d 53        add #-1, r13 ;r3 As==11
>   18: 3d 93        cmp #-1, r13 ;r3 As==11
>   1a: 06 24        jz $+14      ;abs 0x28
>     *dst++ = *src++;
>   1c: be 4f 00 00  mov @r15+, 0(r14) ;
>   20: 2e 53        incd r14  ;
>   22: 3d 53        add #-1, r13 ;r3 As==11
>   24: 3d 93        cmp #-1, r13 ;r3 As==11
>   26: fa 23        jnz $-10      ;abs 0x1c
> }
>   28: 30 41        ret
>




Reply via email to