https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124313
Bug ID: 124313
Summary: mips builds broken in libstdc++ due to TImode .CLZ
ICE.
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: roger at nextmovesoftware dot com
Target Milestone: ---
Target: mips64-elf
Cross-builds (and presumably native bootstraps) are currently broken on MIPS
due to an ICE in expand attempting to expand internal function .CLZ on a TImode
operand, compiling libstdc++-v3/src/c++17/floating_to_chars.cc. This can be
reproduced with:
int foo(unsigned __int128 x) {
return __builtin_clzg(x);
}
which with -O2 on mips64-elf results in:
clz.c: In function 'foo':
clz.c:3:10: internal compiler error: in expand_fn_using_insn, at
internal-fn.cc:270
3 | return __builtin_clzg(x);
| ^~~~~~~~~~~~~~~~~
0x1def05d internal_error(char const*, ...)
../../combined/gcc/diagnostic-global-context.cc:787
0x8a9678 fancy_abort(char const*, int, char const*)
../../combined/gcc/diagnostics/context.cc:1813
0x6fb877 expand_fn_using_insn
../../combined/gcc/internal-fn.cc:270
0xa72e47 expand_call_stmt
../../combined/gcc/cfgexpand.cc:3110
0xa72e47 expand_gimple_stmt_1
../../combined/gcc/cfgexpand.cc:4243
0xa72e47 expand_gimple_stmt
../../combined/gcc/cfgexpand.cc:4390
0xa76c16 expand_gimple_tailcall
../../combined/gcc/cfgexpand.cc:4437
0xa7805e expand_gimple_basic_block
../../combined/gcc/cfgexpand.cc:6480
0xa7a16f execute
../../combined/gcc/cfgexpand.cc:7254
I couldn't find this issue in bugzilla, so I'm filing here hoping someone will
triage it (possibly as a duplicate). Three possible solutions; (1) either
libstdc++ shouldn't be calling __builtin_clzg on TImode on targets that don't
support it, (2) the middle-end's expand_internal_call should be synthesizing
TImode clz from narrower modes, or (3) the MIPS backend (and similar targets)
needs to provide a clzti2 optab in order to build recent libstdc++. I've no
clue which approach is (or approaches are) the preferred way forward.
Thanks in advance.