On 11/06/2015 08:22 AM, Richard Sandiford wrote:
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.
OK to install?

Thanks,
Richard


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.

OK.

jeff



Reply via email to