[Bug tree-optimization/90821] New: missing strlen range after a char store at non-zero index
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Jun 10 20:17:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90821
Bug ID: 90821
Summary: missing strlen range after a char store at non-zero
index
Product: gcc
Version: 9.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: ---
GCC folds the test in f() into a constant but doesn't do the same for the test
in g(), even though both are necessarily false and even though all information
to determine that is available in the strlen pass in both cases.
$ cat a.c && gcc -O2 -S -Wall -Wextra -fdump-tree-optimized=/dev/stdout a.c
char a[4];
void f (void)
{
a[0] = 1;
a[1] = 2;
a[2] = 0;
if (__builtin_strlen (a) > 2) // folded to false
__builtin_abort ();
}
void g (void)
{
a[0] = 1;
a[2] = 0;
if (__builtin_strlen (a) > 2) // not folded
__builtin_abort ();
}
;; Function f (f, funcdef_no=0, decl_uid=1907, cgraph_uid=1, symbol_order=1)
f ()
{
<bb 2> [local count: 1073741824]:
MEM[(char *)&a] = 513;
a[2] = 0;
return;
}
;; Function g (g, funcdef_no=1, decl_uid=1910, cgraph_uid=2, symbol_order=2)
g ()
{
long unsigned int _1;
<bb 2> [local count: 1073741824]:
a[0] = 1;
a[2] = 0;
_1 = __builtin_strlen (&a);
if (_1 == 3)
goto <bb 3>; [0.00%]
else
goto <bb 4>; [100.00%]
<bb 3> [count: 0]:
__builtin_abort ();
<bb 4> [local count: 1073741824]:
return;
}
More information about the Gcc-bugs
mailing list