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

            Bug ID: 83128
           Summary: Unable to optimize {m,c}alloc when strings builtin are
                    used
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: denis.campredon at gmail dot com
  Target Milestone: ---

Currently gcc with -03 is able to optimize 
----------
char f() {
  char * i = (char*)__builtin_malloc(100);

 i[0] = 'a';
 return i[0];
}
----------
to
----------
        mov     al, 97
        ret

But is unable to do the same when string builtins are used with either malloc
or calloc.

---------
char f() {
  char * i = (char*)__builtin_malloc(100);

  __builtin_memcpy(i, "a", 1);
  return i[0];
}
---------

Reply via email to