diff options
author | Kazu Hirata <kazu@cs.umass.edu> | 2004-06-02 18:41:40 +0000 |
---|---|---|
committer | Kazu Hirata <kazu@gcc.gnu.org> | 2004-06-02 18:41:40 +0000 |
commit | 91fa0e3de67af533eeeb8ef494a2bb66187570c1 (patch) | |
tree | 65221ce7e77f96f29e46ef3c29199f2d88f183f4 /gcc | |
parent | dff008b446fd93001c3e0c97d503042c37fa8574 (diff) | |
download | gcc-91fa0e3de67af533eeeb8ef494a2bb66187570c1.zip gcc-91fa0e3de67af533eeeb8ef494a2bb66187570c1.tar.gz gcc-91fa0e3de67af533eeeb8ef494a2bb66187570c1.tar.bz2 |
re PR tree-optimization/15738 ([tree-ssa] Convert strrchr(s, c) to strchr(s, c) if c is known to be 0)
PR tree-optimization/15738.
* builtins.c (fold_builtin_strchr): Transform
strrchr (s, '\0') to strchr (s, '\0').
From-SVN: r82572
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/builtins.c | 15 |
2 files changed, 21 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index bb675bb..8d22422 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2004-06-02 Kazu Hirata <kazu@cs.umass.edu> + + PR tree-optimization/15738. + * builtins.c (fold_builtin_strchr): Transform + strrchr (s, '\0') to strchr (s, '\0'). + 2004-06-02 Steven Bosscher <stevenb@suse.de> * i386.c (ix86_adjust_cost): Don't increase the cost for diff --git a/gcc/builtins.c b/gcc/builtins.c index e44ad61..e265186 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; } } |