https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55212

--- Comment #248 from Kazumoto Kojima <kkojima at gcc dot gnu.org> ---
Created attachment 59102
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=59102&action=edit
a reduced C test case for the wrong code problem c#192

typedef struct { int c[64]; } obj;

extern void bar (int, int, int, int, obj *);
void foo (obj *p)
{
  obj bobj = *p;
  bar (0, 0, 0, 0, &bobj);
}

With "-O2 -m4 -mlra -ffixed-r7 -ffixed-r8 -ffixed-r9 -ffixed-r10 -ffixed-r11
-ffixed-r12 -ffixed-r13", it's compiled to

foo:
        mov.l   r14,@-r15       ! 32    [c=4 l=2]  movsi_ie/8
        mov     r4,r5   ! 23    [c=4 l=2]  movsi_ie/1
        sts.l   pr,@-r15        ! 33    [c=4 l=2]  movsi_ie/10
        mov.w   .L6,r1  ! 34    [c=10 l=2]  *movhi/0
        mov     #31,r6  ! 11    [c=4 l=2]  movsi_ie/2
        mov.l   .L4,r14 ! 29    [c=10 l=2]  movsi_ie/0
        mov     #0,r7   ! 16    [c=4 l=2]  movsi_ie/2
        sub     r1,r15  ! 35    [c=4 l=2]  *subsi3_internal
        mov     r15,r4  ! 30    [c=4 l=2]  movsi_ie/1
        jsr     @r14    ! 12    [c=1 l=2]  block_lump_real_i4/0
        add     #4,r4   ! 31    [c=4 l=2]  *addsi3_compact_lra/0
        mov.l   .L5,r1  ! 27    [c=10 l=2]  movsi_ie/0
        mov     #0,r6   ! 17    [c=4 l=2]  movsi_ie/2
        mov.l   r4,@r15 ! 14    [c=4 l=2]  movsi_ie/8
        mov     #0,r5   ! 18    [c=4 l=2]  movsi_ie/2
        jsr     @r1     ! 20    [c=0 l=2]  calli
        mov     #0,r4   ! 19    [c=4 l=2]  movsi_ie/2

r4 clobbered by block_lump_real_i4 is wrongly used as the 5-th argument of the
bar function.  ffixed-reg options are used to make register starvation.

Reply via email to