https://bugs.llvm.org/show_bug.cgi?id=47159
Bug ID: 47159
Summary: Failure to optimize malloc+memset to calloc
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Scalar Optimizations
Assignee: unassignedb...@nondot.org
Reporter: gabrav...@gmail.com
CC: llvm-bugs@lists.llvm.org
struct S
{
int a;
};
struct S *f()
{
struct S *p = (struct S *)malloc(sizeof(struct S));
memset(p, 0, sizeof(*p));
return p;
}
This can be optimized to `return calloc(sizeof(struct S), 1);`. This
transformation is done by GCC, but not by LLVM. See also
https://godbolt.org/z/MGzfGf.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs