* [Bug target/103622] ICE: Segmentation fault (in altivec_resolve_new_overloaded_builtin)
2021-12-09 7:15 [Bug target/103622] New: ICE: Segmentation fault (in altivec_resolve_new_overloaded_builtin) asolokha at gmx dot com
@ 2021-12-09 9:50 ` linkw at gcc dot gnu.org
2021-12-09 11:48 ` linkw at gcc dot gnu.org
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: linkw at gcc dot gnu.org @ 2021-12-09 9:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103622
Kewen Lin <linkw at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |bergner at gcc dot gnu.org,
| |linkw at gcc dot gnu.org,
| |segher at gcc dot gnu.org,
| |wschmidt at gcc dot gnu.org
--- Comment #1 from Kewen Lin <linkw at gcc dot gnu.org> ---
Confirmed, this requires one e300c3 cross build to reproduce:
2944│ for (; instance != NULL; instance = instance->next)
2945│ {
2946│ bool mismatch = false;
2947├───────────> tree nextparm = TYPE_ARG_TYPES (instance->fntype);
2948│
2949│ for (unsigned int arg_i = 0;
(gdb) p instance->fntype
$1 = <tree 0x0>
The overloaded bif fntype for RS6000_INST_VSEEQP relies on type usi_ftype_tf.
rs6000_instance_info[RS6000_INST_VSEEQP].fntype
= usi_ftype_tf;
if (float128_type_node)
usi_ftype_tf
= build_function_type_list ( unsigned_intSI_type_node,
float128_type_node,
NULL_TREE)
But on e300c3 there is no float128 type support (float128_type_node is NULL).
One thought seems to check instance->fntype first and take (skip) it as
mismatch if it's NULL.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/103622] ICE: Segmentation fault (in altivec_resolve_new_overloaded_builtin)
2021-12-09 7:15 [Bug target/103622] New: ICE: Segmentation fault (in altivec_resolve_new_overloaded_builtin) asolokha at gmx dot com
2021-12-09 9:50 ` [Bug target/103622] " linkw at gcc dot gnu.org
@ 2021-12-09 11:48 ` linkw at gcc dot gnu.org
2021-12-09 14:03 ` linkw at gcc dot gnu.org
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: linkw at gcc dot gnu.org @ 2021-12-09 11:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103622
--- Comment #2 from Kewen Lin <linkw at gcc dot gnu.org> ---
Got exposed from r12-5752, r12-5751 we got the error msg like:
test.c: In function ‘get_float128_exponent’:
test.c:6:5: note: builtin ‘__builtin_vec_scalar_extract_exp’ requires builtin
‘__builtin_vsx_scalar_extract_expq’
6 | return __builtin_vec_scalar_extract_exp (a);
| ^~~~~~
test.c:6:12: error: ‘__builtin_vsx_scalar_extract_expq’ requires ISA 3.0 IEEE
128-bit floating point
6 | return __builtin_vec_scalar_extract_exp (a);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/103622] ICE: Segmentation fault (in altivec_resolve_new_overloaded_builtin)
2021-12-09 7:15 [Bug target/103622] New: ICE: Segmentation fault (in altivec_resolve_new_overloaded_builtin) asolokha at gmx dot com
2021-12-09 9:50 ` [Bug target/103622] " linkw at gcc dot gnu.org
2021-12-09 11:48 ` linkw at gcc dot gnu.org
@ 2021-12-09 14:03 ` linkw at gcc dot gnu.org
2021-12-09 21:24 ` wschmidt at gcc dot gnu.org
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: linkw at gcc dot gnu.org @ 2021-12-09 14:03 UTC (permalink / raw)
To: gcc-bugs
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’
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/103622] ICE: Segmentation fault (in altivec_resolve_new_overloaded_builtin)
2021-12-09 7:15 [Bug target/103622] New: ICE: Segmentation fault (in altivec_resolve_new_overloaded_builtin) asolokha at gmx dot com
` (2 preceding siblings ...)
2021-12-09 14:03 ` linkw at gcc dot gnu.org
@ 2021-12-09 21:24 ` wschmidt at gcc dot gnu.org
2021-12-09 21:37 ` wschmidt at gcc dot gnu.org
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: wschmidt at gcc dot gnu.org @ 2021-12-09 21:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103622
Bill Schmidt <wschmidt at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |wschmidt at gcc dot gnu.org
Target Milestone|--- |12.0
--- Comment #4 from Bill Schmidt <wschmidt at gcc dot gnu.org> ---
I'll have a look.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/103622] ICE: Segmentation fault (in altivec_resolve_new_overloaded_builtin)
2021-12-09 7:15 [Bug target/103622] New: ICE: Segmentation fault (in altivec_resolve_new_overloaded_builtin) asolokha at gmx dot com
` (3 preceding siblings ...)
2021-12-09 21:24 ` wschmidt at gcc dot gnu.org
@ 2021-12-09 21:37 ` wschmidt at gcc dot gnu.org
2021-12-12 16:44 ` [Bug target/103622] [12 Regression] " wschmidt at gcc dot gnu.org
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: wschmidt at gcc dot gnu.org @ 2021-12-09 21:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103622
--- Comment #5 from Bill Schmidt <wschmidt at gcc dot gnu.org> ---
Expected behavior is:
pr103622.c: In function 'get_float128_exponent':
pr103622.c:4:3: error: invalid parameter combination for AltiVec intrinsic
'__builtin_vec_scalar_extract_exp'
4 | return __builtin_vec_scalar_extract_exp (a);
| ^~~~~~
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/103622] [12 Regression] ICE: Segmentation fault (in altivec_resolve_new_overloaded_builtin)
2021-12-09 7:15 [Bug target/103622] New: ICE: Segmentation fault (in altivec_resolve_new_overloaded_builtin) asolokha at gmx dot com
` (4 preceding siblings ...)
2021-12-09 21:37 ` wschmidt at gcc dot gnu.org
@ 2021-12-12 16:44 ` wschmidt at gcc dot gnu.org
2021-12-13 13:54 ` wschmidt at gcc dot gnu.org
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: wschmidt at gcc dot gnu.org @ 2021-12-12 16:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103622
Bill Schmidt <wschmidt at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
Last reconfirmed| |2021-12-12
--- Comment #6 from Bill Schmidt <wschmidt at gcc dot gnu.org> ---
Confirmed.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/103622] [12 Regression] ICE: Segmentation fault (in altivec_resolve_new_overloaded_builtin)
2021-12-09 7:15 [Bug target/103622] New: ICE: Segmentation fault (in altivec_resolve_new_overloaded_builtin) asolokha at gmx dot com
` (5 preceding siblings ...)
2021-12-12 16:44 ` [Bug target/103622] [12 Regression] " wschmidt at gcc dot gnu.org
@ 2021-12-13 13:54 ` wschmidt at gcc dot gnu.org
2021-12-13 14:01 ` wschmidt at gcc dot gnu.org
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: wschmidt at gcc dot gnu.org @ 2021-12-13 13:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103622
--- Comment #7 from Bill Schmidt <wschmidt at gcc dot gnu.org> ---
It seems to me the problem is that long double was resolved to _Float128 when
there is no _Float128 support on the target. There is no specific overloaded
interface that accepts "long double," so there must have been type coercion
involved here.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/103622] [12 Regression] ICE: Segmentation fault (in altivec_resolve_new_overloaded_builtin)
2021-12-09 7:15 [Bug target/103622] New: ICE: Segmentation fault (in altivec_resolve_new_overloaded_builtin) asolokha at gmx dot com
` (6 preceding siblings ...)
2021-12-13 13:54 ` wschmidt at gcc dot gnu.org
@ 2021-12-13 14:01 ` wschmidt at gcc dot gnu.org
2021-12-13 16:16 ` wschmidt at gcc dot gnu.org
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: wschmidt at gcc dot gnu.org @ 2021-12-13 14:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103622
--- Comment #8 from Bill Schmidt <wschmidt at gcc dot gnu.org> ---
Hm, no, it's probably just that it's iterating looking for long double and runs
across this instance with an uninitialized function type. So this patch solves
the problem:
diff --git a/gcc/config/rs6000/rs6000-c.c b/gcc/config/rs6000/rs6000-c.c
index 8e83d97e72f..fc4cc929884 100644
--- a/gcc/config/rs6000/rs6000-c.c
+++ b/gcc/config/rs6000/rs6000-c.c
@@ -2943,6 +2943,12 @@ altivec_resolve_new_overloaded_builtin (location_t loc,
tree fndecl,
for (; instance != NULL; instance = instance->next)
{
+ /* It is possible for an instance to require a data type that isn't
+ defined on this target, in which case instance->fntype will be
+ NULL. */
+ if (!instance->fntype)
+ continue;
+
bool mismatch = false;
tree nextparm = TYPE_ARG_TYPES (instance->fntype);
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/103622] [12 Regression] ICE: Segmentation fault (in altivec_resolve_new_overloaded_builtin)
2021-12-09 7:15 [Bug target/103622] New: ICE: Segmentation fault (in altivec_resolve_new_overloaded_builtin) asolokha at gmx dot com
` (7 preceding siblings ...)
2021-12-13 14:01 ` wschmidt at gcc dot gnu.org
@ 2021-12-13 16:16 ` wschmidt at gcc dot gnu.org
2021-12-15 2:53 ` linkw at gcc dot gnu.org
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: wschmidt at gcc dot gnu.org @ 2021-12-13 16:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103622
--- Comment #9 from Bill Schmidt <wschmidt at gcc dot gnu.org> ---
Patch posted here:
https://gcc.gnu.org/pipermail/gcc-patches/2021-December/586715.html
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/103622] [12 Regression] ICE: Segmentation fault (in altivec_resolve_new_overloaded_builtin)
2021-12-09 7:15 [Bug target/103622] New: ICE: Segmentation fault (in altivec_resolve_new_overloaded_builtin) asolokha at gmx dot com
` (8 preceding siblings ...)
2021-12-13 16:16 ` wschmidt at gcc dot gnu.org
@ 2021-12-15 2:53 ` linkw at gcc dot gnu.org
2022-01-05 22:54 ` cvs-commit at gcc dot gnu.org
2022-01-06 1:41 ` wschmidt at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: linkw at gcc dot gnu.org @ 2021-12-15 2:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103622
--- Comment #10 from Kewen Lin <linkw at gcc dot gnu.org> ---
> test.c: In function ‘get_float128_exponent’:
> test.c:4:5: note: overloaded builtin ‘__builtin_vec_scalar_extract_exp’ is
> implemented by builtin ‘__builtin_vsx_scalar_extract_expq’
> 4 | return __builtin_vec_scalar_extract_exp (a);
> | ^~~~~~
> test.c:4:12: error: ‘__builtin_vsx_scalar_extract_expq’ requires ISA 3.0 IEEE > 128-bit floating point
> 4 | return __builtin_vec_scalar_extract_exp (a);
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Just a record to avoid confusion, the above message was the previously emitted
message before r12-5752 for powerpc-e300c3 cross since it doesn't support ieee
float128. The message is also the same as what I saw on P8 BE with
-mabi=ieeelongdouble, but we will get the message what Bill put if specifying
with -mabi=ibmlongdouble there (that is "invalid parameter combination").
I just noticed that our built-in documents actually note the type should be
"__ieee128", it makes more sense to emit "invalid parameter combination"
instead, so Bill's proposed fix is the best.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/103622] [12 Regression] ICE: Segmentation fault (in altivec_resolve_new_overloaded_builtin)
2021-12-09 7:15 [Bug target/103622] New: ICE: Segmentation fault (in altivec_resolve_new_overloaded_builtin) asolokha at gmx dot com
` (9 preceding siblings ...)
2021-12-15 2:53 ` linkw at gcc dot gnu.org
@ 2022-01-05 22:54 ` cvs-commit at gcc dot gnu.org
2022-01-06 1:41 ` wschmidt at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-01-05 22:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103622
--- Comment #11 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by William Schmidt <wschmidt@gcc.gnu.org>:
https://gcc.gnu.org/g:4ec62dbafe0cb3b79cc635dfb964ef6a7ccc2d40
commit r12-6275-g4ec62dbafe0cb3b79cc635dfb964ef6a7ccc2d40
Author: Bill Schmidt <wschmidt@linux.ibm.com>
Date: Wed Jan 5 16:53:29 2022 -0600
rs6000: Skip overload instances with uninitialized fntype (PR103622)
2022-01-05 Bill Schmidt <wschmidt@linux.ibm.com>
gcc/
PR target/103622
* config/rs6000/rs6000-c.c (altivec_resolve_overloaded_builtin):
Skip over instances with undefined function types.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/103622] [12 Regression] ICE: Segmentation fault (in altivec_resolve_new_overloaded_builtin)
2021-12-09 7:15 [Bug target/103622] New: ICE: Segmentation fault (in altivec_resolve_new_overloaded_builtin) asolokha at gmx dot com
` (10 preceding siblings ...)
2022-01-05 22:54 ` cvs-commit at gcc dot gnu.org
@ 2022-01-06 1:41 ` wschmidt at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: wschmidt at gcc dot gnu.org @ 2022-01-06 1:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103622
Bill Schmidt <wschmidt at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|NEW |RESOLVED
--- Comment #12 from Bill Schmidt <wschmidt at gcc dot gnu.org> ---
Fixed now.
^ permalink raw reply [flat|nested] 13+ messages in thread