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

--- Comment #10 from Oleg Endo <olegendo at gcc dot gnu.org> ---
I was wondering whether it would make sense to convert sequences such as

                             SH4       SH4A
        mov.l   @r15,r3      LS/2      LS/2  
        mul.l   r2,r3        CO/4      EX/3
        sts     macl,r3      CO/3      LS/2
        add     r1,r3        EX/1      EX/1

into
        mov     r15,r0       MT/0      MT/1
        mov.l   r2,@-r15     LS/1      LS/1
        lds     r1,macl      CO/3      LS/1
        mac.l   @r15+,@r0+   CO/4      CO/5
        sts     macl,r3      CO/3      LS/2

Looking simply at the issue cycles (the numbers above) would suggest that it's
not worth doing it, at least not if the value has to be pulled out from the mac
register immediately after the mac operation.  Probably it's not beneficial to
emit a single mac insn if the data is not already in place so that it can be
reached easily with the post-inc addressing.

On the other hand something like ...

int test33 (int* x, int y, int z)
{
  return x[0] * 40 + z;
}

currently compiles to:
        mov.l   @r4,r2
        mov     #40,r1
        mul.l   r1,r2
        sts     macl,r0
        rts
        add     r6,r0

where this one maybe could be better:
        mova    .L40,r0
        lds     r6,macl
        mac.l   @r4+,r0+
        rts
        sts     macl,r0

        .align 2
.L40:   .long   40

Reply via email to