Fix PR 71627 - unable to find a register to spill
Tweak find_valid_class_1 to consider a reg class if atleast one regno in
that class is ok.
Previously, even if no regno was in_hard_reg_set_p, the code goes ahead and
considers rclass as valid. bad was set only if a regno was in the reg
class *and* HARD_REGNO_MODE_OK was false - if both were false, bad wasn't
set and the reload got a wrong rclass. If that happened to be the best
one, this eventually lead to find_reg running out of registers to
spill, because the chosen rclass wouldn't have enough regs.
Also, it expected every regno in rclass to be valid for mode
i.e., if any regno fails HARD_REGNO_MODE_OK, it rejected the rclass. The
comments in the original commit for find_valid_class_1 say atleast one
regno is ok. This was updated to say "class which contains only
registers" when in_hard_reg_set_p was introduced in place of just
TEST_HARD_REG_BIT.
This commit fixes both of the above problems by not breaking out of the loop
on first unavailable regno. Instead, it computes the rclass size consisting
of all regnos in that class valid for the current mode.
If that computed size is zero, the rclass would be skipped, as it won't
beat best_size. Otherwise, the computed size is used to choose the best
rclass, instead of the static size from reg_class_size.
gcc/
2016-10-21 Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com>
PR target/71627
* reload.c (find_valid_class_1): Allow regclass if atleast one
regno in regclass is ok. Compute and use rclass size based on
actually available regnos for mode in rclass.
gcc/testsuite/
2016-10-21 Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com>
PR target/71627
* gcc.target/avr/pr71627.c: New test
From-SVN: r241400