https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85358
Bug ID: 85358 Summary: PowerPC: Using -mabi=ieeelongdouble -mcpu=power9 breaks __ibm128 Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: meissner at gcc dot gnu.org Target Milestone: --- If you switch the default long double type to IEEE 128-bit (-mabi=ieeelongdouble), the GCC compiler will crash. Using this code: __ibm128 add (__ibm128 a, __ibm128 b) { return a+b; } This error is generated: during RTL pass: expand foo02.c: In function ‘add’: foo02.c:1:49: internal compiler error: Segmentation fault __ibm128 add (__ibm128 a, __ibm128 b) { return a+b; } ~^~ 0xb683ff crash_signal /home/meissner/fsf-src/pr85075/gcc/toplev.c:325 0x86bd0f aggregate_value_p(tree_node const*, tree_node const*) /home/meissner/fsf-src/pr85075/gcc/function.c:2040 0x6d76b4 emit_library_call_value_1(int, rtx_def*, rtx_def*, libcall_type, machine_mode, int, std::pair<rtx_def*, machine_mode>*) /home/meissner/fsf-src/pr85075/gcc/calls.c:4771 0xf2ae05 emit_library_call_value(rtx_def*, rtx_def*, libcall_type, machine_mode, rtx_def*, machine_mode) /home/meissner/fsf-src/pr85075/gcc/rtl.h:4156 0xf01ed0 rs6000_expand_float128_convert(rtx_def*, rtx_def*, bool) /home/meissner/fsf-src/pr85075/gcc/config/rs6000/rs6000.c:22489 0x10f318d gen_extenddfkf2(rtx_def*, rtx_def*) /home/meissner/fsf-src/pr85075/gcc/config/rs6000/rs6000.md:7553 0xa608db maybe_emit_unop_insn(insn_code, rtx_def*, rtx_def*, rtx_code) /home/meissner/fsf-src/pr85075/gcc/optabs.c:3547 0xa60988 emit_unop_insn(insn_code, rtx_def*, rtx_def*, rtx_code) /home/meissner/fsf-src/pr85075/gcc/optabs.c:3570 0x80cc05 convert_mode_scalar /home/meissner/fsf-src/pr85075/gcc/expr.c:601 0x80cc05 convert_move(rtx_def*, rtx_def*, int) /home/meissner/fsf-src/pr85075/gcc/expr.c:268 0x80d891 convert_modes(machine_mode, machine_mode, rtx_def*, int) /home/meissner/fsf-src/pr85075/gcc/expr.c:709 0xa6451f expand_binop(machine_mode, optab_tag, rtx_def*, rtx_def*, rtx_def*, int, optab_methods) /home/meissner/fsf-src/pr85075/gcc/optabs.c:1317 0x81b359 expand_expr_real_2(separate_ops*, rtx_def*, machine_mode, expand_modifier) /home/meissner/fsf-src/pr85075/gcc/expr.c:9715 0x808b53 expand_expr_real_1(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool) /home/meissner/fsf-src/pr85075/gcc/expr.c:9918 0x6e8abd expand_expr /home/meissner/fsf-src/pr85075/gcc/expr.h:276 0x6e8abd expand_return /home/meissner/fsf-src/pr85075/gcc/cfgexpand.c:3573 0x6e8abd expand_gimple_stmt_1 /home/meissner/fsf-src/pr85075/gcc/cfgexpand.c:3663 0x6e8abd expand_gimple_stmt /home/meissner/fsf-src/pr85075/gcc/cfgexpand.c:3790 0x6ea667 expand_gimple_basic_block /home/meissner/fsf-src/pr85075/gcc/cfgexpand.c:5819 0x6efdce execute /home/meissner/fsf-src/pr85075/gcc/cfgexpand.c:6425 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions. Now what is happening is since there is hardware support for IEEE 128-bit operations in power9, the GCC compiler decides it can do the calculation of IBM double double in IEEE 128-bit and tries to do the conversion. However, rather than converting to TFmode (long double), it converts to KFmode (__float128/_Float128). However, KFmode isn't properly registered (since TFmode is used for float128), and emit_library_call_value_1 gets a NULL tree type which aggregate_value_p crashes with a NULL pointer. Ideally, for __ibm128 we should NOT try to use __float128 for the arithmetic, since there are cases where the last bit is not accurate.