https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105818
--- Comment #3 from Kewen Lin <linkw at gcc dot gnu.org> --- The different flag bit is OPTION_MASK_SAVE_TOC_INDIRECT. if ((rs6000_isa_flags_explicit & OPTION_MASK_SAVE_TOC_INDIRECT) == 0 && flag_shrink_wrap_separate && optimize_function_for_speed_p (cfun)) rs6000_isa_flags |= OPTION_MASK_SAVE_TOC_INDIRECT; When parsing function foo, the call to optimize_function_for_speed_p return OPTIMIZE_SIZE_MAX as expected, at that time function struct is null. while parsing the decl bar, the cfun is the one created for foo, although there is no cgraph node for it, optimize_function_for_speed_p return OPTIMIZE_SIZE_NO. I think when none cgraph node is found we should still return OPTIMIZE_SIZE_MAX if optimize_size is set. It can fix this issue.