https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118430
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Component|middle-end |tree-optimization Status|UNCONFIRMED |NEW Last reconfirmed| |2025-01-12 Keywords| |missed-optimization, | |rejects-valid Severity|normal |enhancement Summary|musttail false positive on |tail call vs IPA-VRP return |how locals are used |value range with constant | |value --- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Andrew Pinski from comment #4) > Oh for -O2, this is IPA VRP coming into play. > > It is turning: > [[gnu::musttail]] > return tail_call2(opcode); > > into > > tail_call2(opcode); > return 2; s/2/1/ . The error message is definitely wrong. ``` /* We may proceed if there either is no return value, or the return value is identical to the call's return or if the return decl is an empty type variable and the call's return was not assigned. */ if (ret_var && (ret_var != ass_var && !(is_empty_type (TREE_TYPE (ret_var)) && !ass_var))) { maybe_error_musttail (call, _("call uses return slot")); return; } ``` >From EVRP: Using return value range of tail_call2: [irange] int [1, 1] tail call should be able to check the call's return value range to see if it same as the value here. The -O0 case is due to -O0 does do any optimizations and I highly doubt it can handle musttail at all.