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

Oleg Endo <olegendo at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |olegendo at gcc dot gnu.org

--- Comment #4 from Oleg Endo <olegendo at gcc dot gnu.org> ---
Looks like with GCC 13 it now converts the loop into a memset call.

typedef struct {
      int l;
      int b[258];
} S;

void clear2 (S* s )
{
   int i;
   int len = s->l;

   int* p = s->b;
   for (i = 0; i < len; i++)
       p[i] = 0;
}

compiling with GCC 13 -mlra -m2 -ml -O2:

        mov.l   @r4+,r6         ! 6     [c=1 l=2]  movsi_i/5
        cmp/pl  r6              ! 10    [c=4 l=2]  cmpgtsi_t/0
        bf.s    .L1             ! 11    [c=17 l=2]  *cbranch_t
        shll2   r6              ! 16    [c=4 l=2]  ashlsi3_k/1
        mov.l   .L5,r0          ! 19    [c=10 l=2]  movsi_i/0
        jmp     @r0             ! 20    [c=5 l=2]  sibcall_valuei
        mov     #0,r5           ! 17    [c=4 l=2]  movsi_i/2
        .align 1
.L1:
        rts     
        nop                     ! 41    [c=0 l=4]  *return_i
.L6:
        .align 2
.L5:
        .long   _memset


However, compiling with GCC 13 -mlra -m2 -ml -O2 -fno-builtin results in pretty
much the same code as in comment #2

Reply via email to