[Bug tree-optimization/86203] New: duplicate non-constant call to strlen() not folded
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Jun 18 19:04:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86203
Bug ID: 86203
Summary: duplicate non-constant call to strlen() not folded
Product: gcc
Version: 8.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: ---
In the test case below, GCC emits two calls to strlen() even though only one is
necessary: the second call can be replaced by the assignment 'n1 = n0' Cl
$ cat d.c && gcc -O2 -S -Wall -Wextra -fdump-tree-optimized=/dev/stdout d.c
unsigned n0, n1;
void f (const char *s)
{
n0 = __builtin_strlen (s);
n1 = __builtin_strlen (s); // should substitute: n1 = n0;
}
;; Function f (f, funcdef_no=0, decl_uid=1958, cgraph_uid=0, symbol_order=2)
f (const char * s)
{
long unsigned int _1;
unsigned int _2;
long unsigned int _3;
unsigned int _4;
<bb 2> [local count: 1073741825]:
_1 = __builtin_strlen (s_6(D));
_2 = (unsigned int) _1;
n0 = _2;
_3 = __builtin_strlen (s_6(D)); // unnecessary strlen() call
_4 = (unsigned int) _3;
n1 = _4;
return;
}
More information about the Gcc-bugs
mailing list