https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115823
Bug ID: 115823 Summary: Wrong expansion of isnormal optab Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: modula2 Assignee: gaius at gcc dot gnu.org Reporter: stefansf at gcc dot gnu.org Target Milestone: --- Implementing isnormal optab for s390 results in FAIL: gm2/builtins/run/pass/testisnormal.mod compilation, -O FAIL: gm2/builtins/run/pass/testisnormal.mod compilation, -O -g FAIL: gm2/builtins/run/pass/testisnormal.mod compilation, -O3 -fomit-frame-pointer FAIL: gm2/builtins/run/pass/testisnormal.mod compilation, -O3 -fomit-frame-pointer -finline-functions FAIL: gm2/builtins/run/pass/testisnormal.mod compilation, -Os FAIL: gm2/builtins/run/pass/testisnormal.mod compilation, -g UNRESOLVED: gm2/builtins/run/pass/testisnormal.mod execution, -O (link failed) UNRESOLVED: gm2/builtins/run/pass/testisnormal.mod execution, -O -g (link failed) UNRESOLVED: gm2/builtins/run/pass/testisnormal.mod execution, -O3 -fomit-frame-pointer (link failed) UNRESOLVED: gm2/builtins/run/pass/testisnormal.mod execution, -O3 -fomit-frame-pointer -finline-functions (link failed) UNRESOLVED: gm2/builtins/run/pass/testisnormal.mod execution, -Os (link failed) UNRESOLVED: gm2/builtins/run/pass/testisnormal.mod execution, -g (link failed) All tests output /usr/bin/ld: /tmp/ccFZtxN6.o: in function `test': testisnormal.mod:(.text+0x2d4): undefined reference to `__builtin_isnormal' collect2: error: ld returned 1 exit status In math.h we have # define isnormal(x) __builtin_isnormal (x) which means for C code in expand_builtin if (!optimize && !called_as_built_in (fndecl) && fcode != BUILT_IN_FORK && fcode != BUILT_IN_EXECL && fcode != BUILT_IN_EXECV && fcode != BUILT_IN_EXECLP && fcode != BUILT_IN_EXECLE && fcode != BUILT_IN_EXECVP && fcode != BUILT_IN_EXECVE && fcode != BUILT_IN_CLEAR_CACHE && !ALLOCA_FUNCTION_CODE_P (fcode) && fcode != BUILT_IN_FREE && (fcode != BUILT_IN_MEMSET || !(flag_inline_stringops & ILSOP_MEMSET)) && (fcode != BUILT_IN_MEMCPY || !(flag_inline_stringops & ILSOP_MEMCPY)) && (fcode != BUILT_IN_MEMMOVE || !(flag_inline_stringops & ILSOP_MEMMOVE)) && (fcode != BUILT_IN_MEMCMP || !(flag_inline_stringops & ILSOP_MEMCMP))) return expand_call (exp, target, ignore); `called_as_built_in (fndecl)` is always true whereas for gm2 it evaluates to false due to the call side being isnormal (1.0e+0) However, in rtx_for_function_call the symbol reference funexp = XEXP (DECL_RTL (fndecl), 0); is actually __builtin_isnormal which leads to a linker error. Out of curiosity, the test output indicates that this error also happens e.g. for -O3. However, looking into the logs, those tests where never executed with -O3. Kinda surprised me.