-
Jakub Jelinek authored
The expansion of __builtin_iround{,f,l} etc. builtins in some cases emits calls to a different fallback builtin. To locate the right builtin it uses mathfn_built_in_1 with the type of the first argument. If its TYPE_MAIN_VARIANT is {float,double,long_double}_type_node, all is fine, but on the following testcase, because GIMPLE considers scalar float conversions between types with the same mode as useless, TYPE_MAIN_VARIANT of the arg's type is float32_type_node and because there isn't __builtin_lroundf32 returns NULL and we ICE. This patch will first try the type of the first argument of the builtin's prototype (so that say on sizeof(double)==sizeof(long double) target it honors whether it was a *l or non-*l call; though even that can't be 100% trusted, user could incorrectly prototype it) and as fallback the type argument. If neither works, doesn't fallback. 2022-04-11 Jakub Jelinek <jakub@redhat.com> PR rtl-optimization/105211 * builtins.cc (expand_builtin_int_roundingfn_2): If mathfn_built_in_1 fails for TREE_TYPE (arg), retry it with TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (fndecl))) and if even that fails, emit call normally. * gcc.dg/pr105211.c: New test.
Jakub Jelinek authoredThe expansion of __builtin_iround{,f,l} etc. builtins in some cases emits calls to a different fallback builtin. To locate the right builtin it uses mathfn_built_in_1 with the type of the first argument. If its TYPE_MAIN_VARIANT is {float,double,long_double}_type_node, all is fine, but on the following testcase, because GIMPLE considers scalar float conversions between types with the same mode as useless, TYPE_MAIN_VARIANT of the arg's type is float32_type_node and because there isn't __builtin_lroundf32 returns NULL and we ICE. This patch will first try the type of the first argument of the builtin's prototype (so that say on sizeof(double)==sizeof(long double) target it honors whether it was a *l or non-*l call; though even that can't be 100% trusted, user could incorrectly prototype it) and as fallback the type argument. If neither works, doesn't fallback. 2022-04-11 Jakub Jelinek <jakub@redhat.com> PR rtl-optimization/105211 * builtins.cc (expand_builtin_int_roundingfn_2): If mathfn_built_in_1 fails for TREE_TYPE (arg), retry it with TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (fndecl))) and if even that fails, emit call normally. * gcc.dg/pr105211.c: New test.