aboutsummaryrefslogtreecommitdiff
path: root/gcc/builtins.c
diff options
context:
space:
mode:
authorKaveh R. Ghazi <ghazi@teal.rutgers.edu>2000-12-04 01:07:47 +0000
committerKaveh Ghazi <ghazi@gcc.gnu.org>2000-12-04 01:07:47 +0000
commit611b1df48abe697566b141bf52ab35818332e75a (patch)
treea0367c1abc81e13e90391c1db721b347f739984f /gcc/builtins.c
parent55deb0468d6e165470261c04aa299e7df01e73cc (diff)
downloadgcc-611b1df48abe697566b141bf52ab35818332e75a.zip
gcc-611b1df48abe697566b141bf52ab35818332e75a.tar.gz
gcc-611b1df48abe697566b141bf52ab35818332e75a.tar.bz2
builtins.c (expand_builtin_strspn, [...]): Handle another transformation.
* builtins.c (expand_builtin_strspn, expand_builtin_strcspn): Handle another transformation. testsuite: * gcc.c-torture/execute/string-opt-11.c: Add more strspn checks. * gcc.c-torture/execute/string-opt-12.c: Add more strcspn checks. From-SVN: r37986
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r--gcc/builtins.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c
index 1d8e5e2..d6fa5bb 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -2594,12 +2594,13 @@ expand_builtin_strspn (arglist, target, mode)
return expand_expr (size_int (r), target, mode, EXPAND_NORMAL);
}
- /* If the second argument is "", return 0. */
- if (p2 && *p2 == '\0')
+ /* If either argument is "", return 0. */
+ if ((p1 && *p1 == '\0') || (p2 && *p2 == '\0'))
{
- /* Evaluate and ignore argument s1 in case it has
+ /* Evaluate and ignore both arguments in case either one has
side-effects. */
expand_expr (s1, const0_rtx, VOIDmode, EXPAND_NORMAL);
+ expand_expr (s2, const0_rtx, VOIDmode, EXPAND_NORMAL);
return const0_rtx;
}
return 0;
@@ -2638,6 +2639,15 @@ expand_builtin_strcspn (arglist, target, mode)
return expand_expr (size_int (r), target, mode, EXPAND_NORMAL);
}
+ /* If the first argument is "", return 0. */
+ if (p1 && *p1 == '\0')
+ {
+ /* Evaluate and ignore argument s2 in case it has
+ side-effects. */
+ expand_expr (s2, const0_rtx, VOIDmode, EXPAND_NORMAL);
+ return const0_rtx;
+ }
+
/* If the second argument is "", return __builtin_strlen(s1). */
if (p2 && *p2 == '\0')
{