https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119614
--- Comment #25 from Jakub Jelinek <jakub at gcc dot gnu.org> --- As a temporary fix for GCC 15, I think we could always do something like --- gcc/cgraph.h.jj 2025-04-08 14:08:48.517319926 +0200 +++ gcc/cgraph.h 2025-04-10 10:07:19.059246243 +0200 @@ -896,8 +896,8 @@ struct GTY((tag ("SYMTAB_FUNCTION"))) cg indirect_calls (NULL), next_sibling_clone (NULL), prev_sibling_clone (NULL), clones (NULL), clone_of (NULL), call_site_hash (NULL), former_clone_of (NULL), - simdclone (NULL), simd_clones (NULL), ipa_transforms_to_apply (vNULL), - inlined_to (NULL), rtl (NULL), + singleton_retval (NULL), simdclone (NULL), simd_clones (NULL), + ipa_transforms_to_apply (vNULL), inlined_to (NULL), rtl (NULL), count (profile_count::uninitialized ()), count_materialization_scale (REG_BR_PROB_BASE), profile_id (0), unit_id (0), tp_first_run (0), thunk (false), @@ -1408,6 +1408,9 @@ struct GTY((tag ("SYMTAB_FUNCTION"))) cg hash_table<cgraph_edge_hasher> *GTY(()) call_site_hash; /* Declaration node used to be clone of. */ tree former_clone_of; + /* If ipa_return_value_sum range for this function is a CONSTANT_CLASS_P + singleton, store it here. */ + tree singleton_retval; /* If this is a SIMD clone, this points to the SIMD specific information for it. */ --- gcc/lto-cgraph.cc.jj 2025-04-08 14:08:51.978271745 +0200 +++ gcc/lto-cgraph.cc 2025-04-10 10:29:12.536028532 +0200 @@ -474,6 +474,8 @@ lto_output_node (struct lto_simple_outpu FOR_EACH_VEC_ELT (node->ipa_transforms_to_apply, i, pass) streamer_write_hwi_stream (ob->main_stream, pass->static_pass_number); +// stream_write_tree (ob, node->singleton_retval, true); + if (tag == LTO_symtab_analyzed_node) { if (node->inlined_to) @@ -1334,6 +1336,8 @@ input_node (struct lto_file_decl_data *f node->ipa_transforms_to_apply.safe_push ((ipa_opt_pass_d *) pass); } +// node->singleton_retval = stream_read_tree (...); + if (tag == LTO_symtab_analyzed_node) ref = streamer_read_hwi (ib); --- gcc/ipa-prop.cc.jj 2025-04-08 14:08:51.869273262 +0200 +++ gcc/ipa-prop.cc 2025-04-10 11:20:37.071218021 +0200 @@ -6158,6 +6158,13 @@ ipa_record_return_value_range (value_ran ipa_return_value_sum->disable_insertion_hook (); } ipa_return_value_sum->get_create (n)->vr = ipa_get_value_range (val); + tree valr; + if (val.singleton_p (&valr) + && CONSTANT_CLASS_P (valr) + && !tree_expr_nan_p (valr)) + n->singleton_retval = valr; + else + n->singleton_retval = NULL_TREE; if (dump_file && (dump_flags & TDF_DETAILS)) { fprintf (dump_file, "Recording return range "); @@ -6172,7 +6179,7 @@ bool ipa_return_value_range (value_range &range, tree decl) { cgraph_node *n = cgraph_node::get (decl); - if (!n || !ipa_return_value_sum) + if (!n) return false; enum availability avail; n = n->ultimate_alias_target (&avail); @@ -6180,11 +6187,21 @@ ipa_return_value_range (value_range &ran return false; if (n->decl != decl && !useless_type_conversion_p (TREE_TYPE (decl), TREE_TYPE (n->decl))) return false; - ipa_return_value_summary *v = ipa_return_value_sum->get (n); - if (!v) - return false; - v->vr->get_vrange (range); - return true; + if (ipa_return_value_sum) + if (ipa_return_value_summary *v = ipa_return_value_sum->get (n)) + { + v->vr->get_vrange (range); + return true; + } + if (n->singleton_retval) + { + value_range vr (n->singleton_retval, n->singleton_retval); + if (is_a <frange> (vr)) + (as_a <frange> (vr)).clear_nan (); + range = vr; + return true; + } + return false; } /* Reset all state within ipa-prop.cc so that we can rerun the compiler except that I'd need help with the lto-cgraph.cc stuff how to stream node->singleton_retval out and then back in. Tested with non-LTO (and doing the n->singleton_retval handling in the last hunk in precedence over ipa_return_value_sum).