https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103622
--- Comment #3 from Kewen Lin <linkw at gcc dot gnu.org> --- > One thought seems to check instance->fntype first and take (skip) it as > mismatch if it's NULL. This looks like a bad idea, to use long double as the type instead of float128 when type float128 isn't supported might be better. diff --git a/gcc/config/rs6000/rs6000-gen-builtins.c b/gcc/config/rs6000/rs6000-gen-builtins.c index d2e9c4ce547..2b87eef1412 100644 --- a/gcc/config/rs6000/rs6000-gen-builtins.c +++ b/gcc/config/rs6000/rs6000-gen-builtins.c @@ -2473,6 +2473,39 @@ write_fntype_init (char *str) fprintf (init_file, ",\n\t\t\t\t"); } fprintf (init_file, "NULL_TREE);\n"); + + /* Use long_double_type_node instead if float128_type_node isn't + supported, it's to avoid unexpected function types. */ + if (tf_found) + { + char *buf1 = strdup (str); + fprintf (init_file, " else\n "); + fprintf (init_file, " %s\n = build_function_type_list (", buf1); + tok = strtok (buf1, "_"); + if (!strcmp ("tf", tok)) + write_type_node ("ld", true); + else + write_type_node (tok, true); + tok = strtok (0, "_"); + tok = strtok (0, "_"); + if (tok) + fprintf (init_file, ",\n\t\t\t\t"); + + /* Note: A function with no arguments ends with '_ftype_v'. */ + while (tok && strcmp (tok, "v")) + { + if (!strcmp ("tf", tok)) + write_type_node ("ld", true); + else + write_type_node (tok, true); + tok = strtok (0, "_"); + fprintf (init_file, ",\n\t\t\t\t"); + } + fprintf (init_file, "NULL_TREE);\n"); + + free (buf1); + } + free (buf); } The above hacking make the segfault gone and it will emit: test.c: In function ‘get_float128_exponent’: test.c:6:5: error: ‘__builtin_vsx_scalar_extract_expq’ requires ISA 3.0 IEEE 128-bit floating point 6 | return __builtin_vec_scalar_extract_exp (a); | ^~~~~~ test.c:6:5: note: overloaded builtin ‘__builtin_vec_scalar_extract_exp’ is implemented by builtin ‘__builtin_vsx_scalar_extract_expq’