[prev in list] [next in list] [prev in thread] [next in thread]
List: gcc-bugs
Subject: [Bug tree-optimization/80934] New: bzero should be assumed not to escape pointer argument
From: "msebor at gcc dot gnu.org" <gcc-bugzilla () gcc ! gnu ! org>
Date: 2017-05-31 22:43:03
Message-ID: bug-80934-4 () http ! gcc ! gnu ! org/bugzilla/
[Download RAW message or body]
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80934
Bug ID: 80934
Summary: bzero should be assumed not to escape pointer argument
Product: gcc
Version: 7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
Target Milestone: ---
Similarly to a call to memset, a call to bzero can be assumed not to escape its
pointer argument. GCC takes advantage of this knowledge by optimizing function
h() below but it doesn't do the same for function g(), even though it could.
See also bug 80933 for another missed optimization related to bzero.
$ cat a.c && gcc -O2 -S -Wall -fdump-tree-optimized=/dev/stdout a.c
void f (void);
void g (void)
{
char d[32];
__builtin_bzero (d, sizeof d);
f ();
if (*d != 0)
__builtin_abort ();
}
void h (void)
{
char d[32];
__builtin_memset (d, 0, sizeof d);
f ();
if (*d != 0)
__builtin_abort ();
}
;; Function g (g, funcdef_no=0, decl_uid=1795, cgraph_uid=0, symbol_order=0)
g ()
{
char d[32];
char _1;
<bb 2> [100.00%]:
__builtin_bzero (&d, 32);
f ();
_1 = d[0];
if (_1 != 0)
goto <bb 3>; [0.04%]
else
goto <bb 4>; [99.96%]
<bb 3> [0.04%]:
__builtin_abort ();
<bb 4> [99.96%]:
d ={v} {CLOBBER};
return;
}
;; Function h (h, funcdef_no=1, decl_uid=1799, cgraph_uid=1, symbol_order=1)
h ()
{
<bb 2> [100.00%]:
f (); [tail call]
return;
}=
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic