builtins.c (c_strlen): Use TREE_STRING_LENGTH - 1 for max.
authorJakub Jelinek <jakub@redhat.com>
Thu, 9 Nov 2000 09:07:44 +0000 (10:07 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 9 Nov 2000 09:07:44 +0000 (10:07 +0100)
commit2dee4af12b1f2a1262a88bdfa40e5a9db5374663
tree7e4c441f58d15d9c8077a944d506d9f9d2da8ba7
parent54d87db8696d7dd6307ba7f5e54ec27a22d42348
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
gcc/ChangeLog
gcc/builtins.c
gcc/builtins.def
gcc/c-common.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/string-opt-1.c
gcc/testsuite/gcc.c-torture/execute/string-opt-3.c [new file with mode: 0644]
gcc/testsuite/gcc.c-torture/execute/string-opt-4.c [new file with mode: 0644]
gcc/testsuite/gcc.c-torture/execute/string-opt-5.c [new file with mode: 0644]