[Bug tree-optimization/87900] malloc + memset to calloc doesn't work for aggregate initialization
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Nov 6 17:56:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87900
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2018-11-06
CC| |msebor at gcc dot gnu.org
Blocks| |83819
Ever confirmed|0 |1
--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
Confirmed. Below is an enhanced test case and the output:
$ cat u.c && gcc -O2 -S -Wall -fdump-tree-optimized=/dev/stdout u.c
struct S { int a[1024]; };
struct S *foo () // not transformed
{
struct S *p = (struct S *)__builtin_malloc (sizeof (struct S));
*p = (struct S){};
return p;
}
struct S *bar () // transformed into calloc()
{
struct S *p = (struct S *)__builtin_malloc (sizeof (struct S));
__builtin_memset (p, 0, sizeof *p);
return p;
}
;; Function foo (foo, funcdef_no=0, decl_uid=1907, cgraph_uid=1,
symbol_order=0)
foo ()
{
struct S * p;
<bb 2> [local count: 1073741824]:
p_3 = __builtin_malloc (4096);
*p_3 = {};
return p_3;
}
;; Function bar (bar, funcdef_no=1, decl_uid=1911, cgraph_uid=2,
symbol_order=1)
bar ()
{
struct S * p;
<bb 2> [local count: 1073741824]:
p_3 = __builtin_calloc (4096, 1); [tail call]
return p_3;
}
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83819
[Bug 83819] [meta-bug] missing strlen optimizations
More information about the Gcc-bugs
mailing list