https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118125
--- Comment #10 from Martin Jambor <jamborm at gcc dot gnu.org> --- For some reason, unlikely_executed_stmt_p (and thus unlikely_executed_bb_p) do not see that __builtin_unreachable is a cold function: (gdb) pt decl <function_decl 0x7fffbf5e7400 __builtin_unreachable type <function_type 0x7fffbf5e6498 type <void_type 0x7fffbf61cf18 void VOID align:8 warn_if_not_align:0 symtab:0 alias-set -1 structural-equality pointer_to_this <pointer_type 0x7fffbf624000>> QI size <integer_cst 0x7fffbf602eb8 constant 8> unit-size <integer_cst 0x7fffbf602ed0 constant 1> align:8 warn_if_not_align:0 symtab:0 alias-set -1 structural-equality arg-types <tree_list 0x7fffbf61bde8 value <void_type 0x7fffbf61cf18 void>> pointer_to_this <pointer_type 0x7fffbe62e540>> readonly volatile nothrow public external built-in QI <built-in>:0:0 align:8 warn_if_not_align:0 built-in: BUILT_IN_NORMAL:BUILT_IN_UNREACHABLE context <translation_unit_decl 0x7fffbf4a6000 source/base/auto_derivative_function.cc> attributes <tree_list 0x7fffbf5e4a78 purpose <identifier_node 0x7fffbf649e38 nothrow> chain <tree_list 0x7fffbf5e4a50 purpose <identifier_node 0x7fffbf649e60 leaf> chain <tree_list 0x7fffbf5e4a28 purpose <identifier_node 0x7fffbf649e10 noreturn> chain <tree_list 0x7fffbf5e4a00 purpose <identifier_node 0x7fffbf649d48 const>>>>>> (gdb) pt 0x7fffbf5e4a00 <tree_list 0x7fffbf5e4a00 purpose <identifier_node 0x7fffbf649d48 const>> Patching the function with the following also restores the run-time performance of the benchmark: diff --git a/gcc/predict.cc b/gcc/predict.cc index ef31c48bfe2..d3fc2f85414 100644 --- a/gcc/predict.cc +++ b/gcc/predict.cc @@ -843,6 +843,8 @@ unlikely_executed_stmt_p (gimple *stmt) if (lookup_attribute ("cold", DECL_ATTRIBUTES (decl)) && !lookup_attribute ("cold", DECL_ATTRIBUTES (current_function_decl))) return true; + if (fndecl_built_in_p (decl, BUILT_IN_UNREACHABLE)) + return true; cgraph_node *n = cgraph_node::get (decl); if (!n)