https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57485
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Component|middle-end |tree-optimization Depends on| |23384 --- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> --- The pass does almost no analysis: static bool dest_safe_for_nrv_p (gcall *call) { tree dest = gimple_call_lhs (call); dest = get_base_address (dest); if (! dest) return false; if (TREE_CODE (dest) == SSA_NAME) return true; if (call_may_clobber_ref_p (call, dest, false) || ref_maybe_used_by_stmt_p (call, dest, false)) return false; return true; } For this case, we could just simplely to see if this is the first statement in the first bb and that would fix this case. The other thing could be done if the vuse of the call is the incoming vop, check the arguments of the function. But really I think this is just another case of PR 23384 (escaped set not being flow sensitive). Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=23384 [Bug 23384] escaped set should be flow sensitive