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

--- Comment #14 from Oleg Endo <olegendo at gcc dot gnu.org> ---
Just wanted to clarify the reason why the examples in the description have
'-fno-ivopts', as it caused some confusion on the mailing list:

int test_0 (char* p, int c)
{
  int r = 0;
  r += *p++;
  r += *p++;
  r += *p++;
  return r;
}

compiled with -m4 -O2:

        mov.b   @(1,r4),r0
        mov.b   @r4,r1
        add     r0,r1
        mov.b   @(2,r4),r0
        rts
        add     r1,r0

compiled with -m4 -Os:

        mov.b   @(1,r4),r0
        mov.b   @r4,r2
        add     r0,r2
        mov.b   @(2,r4),r0
        add     r0,r2
        rts
        mov     r2,r0

As seen above, the memory accesses are turned into reg+disp addressing,
although on SH using post-inc addressing would be cheaper (as it is also
reported 'sh_address_cost').
Turning off ivopts leaves the post-inc addressing and points out the original
problem of this PR.  I believe that the proper fix for this would be having PR
56590 fixed.

Reply via email to