[PATCH] If using branch likelies in MIPS sync code fill the delay slot with a nop

Andrew Bennett Andrew.Bennett@imgtec.com
Tue Nov 18 15:32:00 GMT 2014


>  OK, this does look to me like the correct way to address the issue, but
> where is the second NOP that you previously mentioned?  I fail to see it
> here and this code can't be made any better, there isn't anything you
> could possibly schedule into the delay slot as there is nothing else to
> do in this loop.

The following testcase shows this occurring.

short v, count, ret;

int
main ()
{
  v = 0;
  count = 0;

  __atomic_exchange_n (&v, count + 1, __ATOMIC_RELAXED);

  return 0;
}

Produces (for the atomic operation):

       .set    noat
        sync
1:
        ll      $3,0($5)
        and     $1,$3,$4
        bne     $1,$7,2f
        and     $1,$3,$6
        or      $1,$1,$8
        sc      $1,0($5)
        beql    $1,$0,1b
        nop
        nop
        sync
2:
        .set    at


Regards,



Andrew



More information about the Gcc-patches mailing list