[patch] More thorough checking in reg_fits_class_p

Richard Sandiford rdsandiford@googlemail.com
Wed May 2 13:00:00 GMT 2012


Jim MacArthur <jim.macarthur@arm.com> writes:
> New Changelog text:
>
> 2012-05-02 Jim MacArthur<jim.macarthur@arm.com>
> * recog.c (reg_fits_class_p): Check both regno and regno + offset are
> hard registers.

Thanks.  I still think the final:

> +	  && HARD_REGISTER_NUM_P (end_hard_regno (regno + offset, mode))

check belongs in in_hard_reg_set_p, since most callers don't (and IMO
shouldn't need to) check this.  The idea behind adding these functions
was to commonise various bits of code that were doing the same checks
in slightly different ways.  Requiring each caller to check the end
register would go against that to some extent.

E.g. the code could be:

  end_regno = end_hard_regno (mode, regno);
  if (!HARD_REGISTER_NUM_P (end_regno))
    return false;

  while (++regno < end_regno)
    if (!TEST_HARD_REG_BIT (regs, regno))
      return false;

Or alternatively we could change hard-reg-set.h so that HARD_REG_SET
is big enough to store a bit for FIRST_PSEUDO_REGISTER.  I don't mind
which, but others might.

Looks good otherwise.  And for the record, I can't approve this anyway. :-)

Richard



More information about the Gcc-patches mailing list