summaryrefslogtreecommitdiffstats
path: root/gcc/builtins.c
diff options
context:
space:
mode:
authorghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4>2000-12-04 01:07:47 +0000
committerghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4>2000-12-04 01:07:47 +0000
commitfb1f44c56487da3b8f3bb83ff9162551a076dd54 (patch)
treea0367c1abc81e13e90391c1db721b347f739984f /gcc/builtins.c
parent8850b4796769773c4e0a78d27b9718de78959044 (diff)
downloadppe42-gcc-fb1f44c56487da3b8f3bb83ff9162551a076dd54.tar.gz
ppe42-gcc-fb1f44c56487da3b8f3bb83ff9162551a076dd54.zip
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@37986 138bc75d-0d04-0410-961f-82ee72b054a4
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 1d8e5e24dbd..d6fa5bb1f0b 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')
{
OpenPOWER on IntegriCloud