This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: function_invariant_p versus rtx_varies_p


> function_invariant_p has the comment:
> 
> /* Return nonzero if the rtx X is invariant over the current function.  */
> 
> rtx_varies_p has the comment:
> 
> /* Return 1 if X has a value that can vary even between two
>    executions of the program.  0 means X can be compared reliably
>    against certain constants or near-constants.
>    The frame pointer and the arg pointer are considered constant.  */
> 
> There seems to be a fair amount of overlap between these two functions.
> Any obvious reason not to replace uses of function_invariant_p with
> rtx_varies_p and kill function_invariant_p?

The current implementation of rtx_varies_p would allow to do that, but
the documented purpose of it does not.

It seems that rtx_varies_p is allowed to return 0 for a register even if
that register assumes different values at different points in the same
function, as long as these values are uniform for all program invokations.

On the other hand, registers like the frame pointer, which vary depending on
abount of stack consumed by the the backtrace, should be considered varying
if any caller in the backtrace might have called alloca with an argument
that depends on program arguments or input that has been read.

I must confess that this doesn't make any sense to me.  Maybe the comment
is just bogus.  But than, it is replicated in front of cse_rtx_varies_p.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]