[llvm-bugs] [Bug 47159] New: Failure to optimize malloc+memset to calloc
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Aug 13 14:48:25 PDT 2020
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: unassignedbugs at nondot.org
Reporter: gabravier at gmail.com
CC: llvm-bugs at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200813/e5392e78/attachment.html>
More information about the llvm-bugs
mailing list