This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] var-tracking.c speedups
On Tue, Jun 23, 2009 at 06:50:12PM +0200, Paolo Bonzini wrote:
> static inline int /* should be bool but that is a separate change */
> rtx_equal_p (const_rtx x, const_rtx y)
> {
> if (x == y)
> return 1;
> if (x == NULL_RTX || y == NULL_RTX)
> return 0;
> if (GET_CODE (x) != GET_CODE (y))
> return 0;
> return rtx_equal_p_cb_1 (x, y, NULL);
> }
>
> static inline int /* should be bool but that is a separate change */
> rtx_equal_p_cb (const_rtx x, const_rtx y, yaddayadda)
> {
> if (x == y)
> return 1;
> if (x == NULL_RTX || y == NULL_RTX)
> return 0;
> if (GET_CODE (x) != GET_CODE (y))
> return 0;
> return rtx_equal_p_cb_1 (x, y, yaddayadda);
> }
>
> so that you can remove the common checks from the callee, too.
While that addresses primarily the tail call and not checking/passing the
callback through recursively, I think moving some of the checks to the
callers is a good idea; I guess in many cases gcc will be able to optimize away
the NULL pointer checks in the callers at least.
BTW, var-tracking.c calls rtx_equal_p in a weird way:
if ((REG_P (vui[jj].lc->loc)
&& REG_P (node->loc)
&& REGNO (vui[jj].lc->loc) == REGNO (node->loc))
|| rtx_equal_p (vui[jj].lc->loc, node->loc))
If that is because it doesn't care about REG mode, when it already knows
that it is a REG it shouldn't call rtx_equal_p at all.
So it could use something like:
/* Like rtx_equal_p, but assumes x and y are non-NULL and for REGs ignores
mode. */
static inline bool
vt_rtx_equal (const_rtx x, const_rtx y)
{
if (x == y)
return true;
if (GET_CODE (x) != GET_CODE (y))
return false;
if (REG_P (x))
return REGNO (x) == REGNO (y);
return rtx_equal_p_cb_1 (x, y, NULL);
}
Jakub