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

            Bug ID: 114228
           Summary: memset/memcpy loop not always recognised with -Os
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: denis.campredon at gmail dot com
  Target Milestone: ---

typedef __SIZE_TYPE__ size_t;
void baz(char *);

void foo( char *__restrict buff, const char*__restrict input)
{
    size_t max = __builtin_strlen (input);
    for(size_t i = 0 ; i < max; ++i)
        buff[i] = 0;

    baz(buff);
}

void bar( char *__restrict buff, const char*__restrict input)
{
    size_t max = __builtin_strlen (input);
    for(size_t i = 0 ; i < max; ++i)
        buff[i] = input[i];

    baz(buff);
}
--------------

The code above, compiled with -Os, the current trunk fails to convert the two
loops into memcpy/memset.

gcc 13.2 is able to convert the loops into a call.

Reply via email to