[Bug tree-optimization/15743] New: Fold index() at tree level.
kazu at cs dot umass dot edu
gcc-bugzilla@gcc.gnu.org
Mon May 31 22:01:00 GMT 2004
char *
foo (void)
{
const char *s = "abcd";
int c = 'p';
return index (s, c);
}
I get:
foo ()
{
int c;
const char * s;
char * T.0;
<bb 0>:
T.0_3 = index ("abcd", 112) [tail call];
return T.0_3;
}
The fix is pretty easy.
Index: builtins.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/builtins.c,v
retrieving revision 1.328
diff -u -r1.328 builtins.c
--- builtins.c 30 May 2004 21:05:20 -0000 1.328
+++ builtins.c 31 May 2004 06:44:31 -0000
@@ -7837,6 +7837,7 @@
case BUILT_IN_STRNCPY:
return fold_builtin_strncpy (exp);
+ case BUILT_IN_INDEX:
case BUILT_IN_STRCHR:
return fold_builtin_strchr (exp, false);
I'll post the patch to gcc-patches after testing it.
--
Summary: Fold index() at tree level.
Product: gcc
Version: 3.5.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: enhancement
Priority: P2
Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: kazu at cs dot umass dot edu
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15743
More information about the Gcc-bugs
mailing list