[patch] builtins.c: Fix PR tree-optimization/15743.
Kazu Hirata
kazu@cs.umass.edu
Mon May 31 20:57:00 GMT 2004
Hi,
Attached is a patch to fix PR tree-optimization/15743.
Consider:
char *
foo (void)
{
const char *s = "abcd";
int c = 'p';
return index (s, c);
}
The last tree-ssa form looks like so:
foo ()
{
int c;
const char * s;
char * T.0;
<bb 0>:
T.0_3 = index ("abcd", 112) [tail call];
return T.0_3;
}
Note that index() is not folded.
The patch solves this problem by having fold_builtin_1() handle
index() just like strchr().
rindex() is handled likewise.
Tested on i686-pc-linux-gnu. OK to apply?
Kazu Hirata
2004-05-31 Kazu Hirata <kazu@cs.umass.edu>
PR tree-optimization/15743.
* builtins.c (fold_builtin_1): Fold index() and rindex().
Index: builtins.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/builtins.c,v
retrieving revision 1.329
diff -u -r1.329 builtins.c
--- builtins.c 31 May 2004 09:13:33 -0000 1.329
+++ builtins.c 31 May 2004 09:26:24 -0000
@@ -7838,9 +7838,11 @@
case BUILT_IN_STRNCPY:
return fold_builtin_strncpy (exp);
+ case BUILT_IN_INDEX:
case BUILT_IN_STRCHR:
return fold_builtin_strchr (exp, false);
+ case BUILT_IN_RINDEX:
case BUILT_IN_STRRCHR:
return fold_builtin_strchr (exp, true);
More information about the Gcc-patches
mailing list