On Sat, Apr 19, 2025 at 08:33:48PM -0700, Andrew Pinski wrote: > > + { > > + tree other_value = NULL_TREE; > > + /* If we have a function call that we know the return value is > > the same > > + as the argument, try the argument too. */ > > + int flags = gimple_call_return_flags (call); > > + if ((flags & ERF_RETURNS_ARG) != 0 > > + && (flags & ERF_RETURN_ARG_MASK) < gimple_call_num_args > > (call)) > > + other_value = gimple_call_arg (call, flags & > > ERF_RETURN_ARG_MASK);
I think this needs to verify that other_value's type is uselessly convertible to TREE_TYPE (ret_var). Because just relying on operand_equal_p returning false otherwise wouldn't work. E.g. if call is memcpy, and you pass say NULL as the first argument to it (and some pointer and some non-constant as last), but the function returns unsigned char 0, you don't want to do a tail call just because NULL is equal to that unsigned char 0. Sure, on lots of targets/ABIs that will in this particular case work fine, but isn't guaranteed to work on all. Perhaps on 32-bit arches if function returns 0ULL? Jakub