From 43c77eaa7684a741554c41a07d954bdab755ca1e Mon Sep 17 00:00:00 2001 From: kazu Date: Wed, 2 Jun 2004 18:41:40 +0000 Subject: [PATCH] PR tree-optimization/15738. * builtins.c (fold_builtin_strchr): Transform strrchr (s, '\0') to strchr (s, '\0'). git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@82572 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 6 ++++++ gcc/builtins.c | 15 +++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index bb675bb3fea..8d22422d993 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2004-06-02 Kazu Hirata + + PR tree-optimization/15738. + * builtins.c (fold_builtin_strchr): Transform + strrchr (s, '\0') to strchr (s, '\0'). + 2004-06-02 Steven Bosscher * i386.c (ix86_adjust_cost): Don't increase the cost for diff --git a/gcc/builtins.c b/gcc/builtins.c index e44ad61b7b2..e2651866d63 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -7123,6 +7123,21 @@ fold_builtin_strchr (tree exp, bool actually_strrchr) ssize_int (r - p1)))); } + if (actually_strrchr) + { + tree fn; + + if (!integer_zerop (s2)) + return 0; + + fn = implicit_built_in_decls[BUILT_IN_STRCHR]; + if (!fn) + return 0; + + /* Transform strrchr(s1, '\0') to strchr(s1, '\0'). */ + return build_function_call_expr (fn, arglist); + } + return 0; } } -- 2.11.4.GIT