Move const char * -> int/fp folds to fold-const-call.c
authorRichard Sandiford <richard.sandiford@arm.com>
Sat, 7 Nov 2015 10:10:44 +0000 (10:10 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Sat, 7 Nov 2015 10:10:44 +0000 (10:10 +0000)
commitdf838ef0f1a11355a217ab11ed8546dd97873870
tree0a6fba6186ee90f2710a360da3bcb509e1e7f047
parentdb9bd5d5752356a71b1ce6986f30c164c39cf51d
Move const char * -> int/fp folds to fold-const-call.c

This patch moves folds that deal with constant string arguments and
return a constant integer or floating-point value.  For example, it
handles strcmp ("foo", "bar") but not strstr ("foobar", "bar"),
which wouldn't currently be accepted by the gimple folders.

The builtins.c folding for strlen (via c_strlen) is a bit more general
than what the fold-const-call.c code does (and more general than we need
for the gimple folders).  I've therefore left it as-is, even though it
partially duplicates the new code.

Tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabi.

gcc/
* builtins.c (fold_builtin_nan): Delete.
(fold_builtin_memcmp): Remove case where both arguments are constant.
(fold_builtin_strcmp, fold_builtin_strncmp): Likewise.
(fold_builtin_strspn, fold_builtin_strcspn): Likewise.
(fold_builtin_1): Remove BUILT_IN_NAN* handling.
* fold-const-call.c: Include fold-const.h.
(host_size_t_cst_p): New function.
(build_cmp_result, fold_const_builtin_nan): Likewise.
(fold_const_call_1): New function, split out from...
(fold_const_call): ...here (for all three interfaces).  Handle
constant nan, nans, strlen, strcmp, strncmp, strspn and strcspn.

From-SVN: r229922
gcc/ChangeLog
gcc/builtins.c
gcc/fold-const-call.c