The following fixes missed constant folding of __builtin_signbit and friends. The first issue is that the calls were never detected as having compatible arguments because the FE builds the function types in a wrong way (they should be variadic but have 'void', even multiple!, arguments).
The second issue is that the gimplifier "auto-detection" of whether GCC may use a function implicitely relies on builtin_decl_declared_p, sth not provided by the FE either. But at least for constant folding the checking for this feature in gimple_simplify is premature - if we'd ever generate the function it was there in the first place. Bootstrap / regtest pending on x86_64-unknown-linux-gnu. Are the fortran parts ok? Thanks, Richard. 2015-10-28 Richard Biener <rguent...@suse.de> * gimple-match-head.c (gimple_simplify): Remove premature checking of builtin_decl_implicit of function calls we simplify. fortran/ * f95-lang.c: Properly build variadic types for classification and comparison builtins. Index: gcc/gimple-match-head.c =================================================================== *** gcc/gimple-match-head.c (revision 229484) --- gcc/gimple-match-head.c (working copy) *************** gimple_simplify (gimple *stmt, *** 751,757 **** tree decl = TREE_OPERAND (fn, 0); if (DECL_BUILT_IN_CLASS (decl) != BUILT_IN_NORMAL - || !builtin_decl_implicit (DECL_FUNCTION_CODE (decl)) || !gimple_builtin_call_types_compatible_p (stmt, decl)) return false; --- 752,757 ---- Index: gcc/fortran/f95-lang.c =================================================================== *** gcc/fortran/f95-lang.c (revision 229484) --- gcc/fortran/f95-lang.c (working copy) *************** gfc_init_builtin_functions (void) *** 988,995 **** /* Type-generic floating-point classification built-ins. */ ! ftype = build_function_type_list (integer_type_node, ! void_type_node, NULL_TREE); gfc_define_builtin ("__builtin_isfinite", ftype, BUILT_IN_ISFINITE, "__builtin_isfinite", ATTR_CONST_NOTHROW_LEAF_LIST); gfc_define_builtin ("__builtin_isinf", ftype, BUILT_IN_ISINF, --- 988,994 ---- /* Type-generic floating-point classification built-ins. */ ! ftype = build_function_type (integer_type_node, NULL_TREE); gfc_define_builtin ("__builtin_isfinite", ftype, BUILT_IN_ISFINITE, "__builtin_isfinite", ATTR_CONST_NOTHROW_LEAF_LIST); gfc_define_builtin ("__builtin_isinf", ftype, BUILT_IN_ISINF, *************** gfc_init_builtin_functions (void) *** 1003,1010 **** gfc_define_builtin ("__builtin_signbit", ftype, BUILT_IN_SIGNBIT, "__builtin_signbit", ATTR_CONST_NOTHROW_LEAF_LIST); ! ftype = build_function_type_list (integer_type_node, void_type_node, ! void_type_node, NULL_TREE); gfc_define_builtin ("__builtin_isless", ftype, BUILT_IN_ISLESS, "__builtin_isless", ATTR_CONST_NOTHROW_LEAF_LIST); gfc_define_builtin ("__builtin_islessequal", ftype, BUILT_IN_ISLESSEQUAL, --- 1002,1008 ---- gfc_define_builtin ("__builtin_signbit", ftype, BUILT_IN_SIGNBIT, "__builtin_signbit", ATTR_CONST_NOTHROW_LEAF_LIST); ! ftype = build_function_type (integer_type_node, NULL_TREE); gfc_define_builtin ("__builtin_isless", ftype, BUILT_IN_ISLESS, "__builtin_isless", ATTR_CONST_NOTHROW_LEAF_LIST); gfc_define_builtin ("__builtin_islessequal", ftype, BUILT_IN_ISLESSEQUAL,