aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-common.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2000-11-09 10:07:44 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2000-11-09 10:07:44 +0100
commit2dee4af12b1f2a1262a88bdfa40e5a9db5374663 (patch)
tree7e4c441f58d15d9c8077a944d506d9f9d2da8ba7 /gcc/c-common.c
parent54d87db8696d7dd6307ba7f5e54ec27a22d42348 (diff)
downloadgcc-2dee4af12b1f2a1262a88bdfa40e5a9db5374663.zip
gcc-2dee4af12b1f2a1262a88bdfa40e5a9db5374663.tar.gz
gcc-2dee4af12b1f2a1262a88bdfa40e5a9db5374663.tar.bz2
builtins.c (c_strlen): Use TREE_STRING_LENGTH - 1 for max.
* builtins.c (c_strlen): Use TREE_STRING_LENGTH - 1 for max. (c_getstr): New function. (expand_builtin_strstr): Do nothing if -fcheck-memory-usage. If both arguments are constant string, optimize out. (expand_builtin_strchr, expand_builtin_strrchr): New functions. (expand_builtin_strpbrk): Use c_getstr, do nothing if -fcheck-memory-usage. (expand_builtin_fputs): Likewise. (expand_builtin_strcmp): Add MODE argument. Use even if !HAVE_cmpstrsi. Optimize the case when both arguments are constant strings. (expand_builtin): Adjust expand_builtin_strcmp caller. Call expand_builtin_strchr and expand_builtin_strrchr. * c-common.c (c_common_nodes_and_builtins): Add strchr and strrchr builtins. * builtins.def (BUILT_IN_STRRCHR): Add. * gcc.c-torture/execute/string-opt-1.c: Add test for strstr with both arguments constant strings. * gcc.c-torture/execute/string-opt-3.c: New test. * gcc.c-torture/execute/string-opt-4.c: New test. * gcc.c-torture/execute/string-opt-5.c: New test. From-SVN: r37338
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r--gcc/c-common.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c
index 247145c..0482a83 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -5179,6 +5179,8 @@ c_common_nodes_and_builtins ()
built_in_decls[BUILT_IN_STRCHR] =
builtin_function ("__builtin_strchr", string_ftype_string_int,
BUILT_IN_STRCHR, BUILT_IN_NORMAL, "strchr");
+ builtin_function ("__builtin_strrchr", string_ftype_string_int,
+ BUILT_IN_STRRCHR, BUILT_IN_NORMAL, "strrchr");
builtin_function ("__builtin_strcpy", string_ftype_ptr_ptr,
BUILT_IN_STRCPY, BUILT_IN_NORMAL, "strcpy");
builtin_function ("__builtin_strlen", strlen_ftype,
@@ -5249,6 +5251,10 @@ c_common_nodes_and_builtins ()
BUILT_IN_NORMAL, NULL_PTR);
builtin_function ("strstr", string_ftype_string_string, BUILT_IN_STRSTR,
BUILT_IN_NORMAL, NULL_PTR);
+ builtin_function ("strchr", string_ftype_string_int, BUILT_IN_STRCHR,
+ BUILT_IN_NORMAL, NULL_PTR);
+ builtin_function ("strrchr", string_ftype_string_int, BUILT_IN_STRRCHR,
+ BUILT_IN_NORMAL, NULL_PTR);
builtin_function ("strpbrk", string_ftype_string_string, BUILT_IN_STRPBRK,
BUILT_IN_NORMAL, NULL_PTR);
builtin_function ("strcpy", string_ftype_ptr_ptr, BUILT_IN_STRCPY,