middle-end/5100: Wrong register class selected by find_valid_class
Marco Altieri
maltieri@nergal.it
Mon Apr 15 06:39:00 GMT 2002
In a simplified example we have only 4 registers (named 0, 1, 2, 3)
and 3 classes of registers:
EVEN_REGS = { 0, 2 }
ODD_REGS = { 1, 3 }
GENERAL_REGS = { 0, 1, 2, 3 }
A pointer can be reloaded only on even/odd pair. In this simplified
example the possible pair are only (0, 1) and (2, 3).
The macro HARD_REGNO_MODE_OK have to return a not null
value for the Pmode mode only for registers 0 and 2:
HARD_REGNO_MODE_OK(0, Pmode) = 1
HARD_REGNO_MODE_OK(1, Pmode) = 0
HARD_REGNO_MODE_OK(2, Pmode) = 1
HARD_REGNO_MODE_OK(3, Pmode) = 0
find_valid_class have to return GENERAL_REGS because EVEN_REGS
and ODD_REGS have not any even/odd pair.
But the algorithm, used in find_valid_class, rejects GENERAL_REGS
and accepts EVEN_REGS.
Infact when
(regno == 0 || regno == 2) &&
m1 == Pmode &&
class == GENERAL_REGISTER &&
n == 1
we have:
HARD_REGNO_MODE_OK (regno + n, m1) == 0
TEST_HARD_REG_BIT (reg_class_contents[class], regno) == 1
TEST_HARD_REG_BIT (reg_class_contents[class], regno + n) == 1
and when
(regno == 0 || regno == 2) &&
m1 == Pmode &&
class == EVEN_REGS &&
n == 1
we have:
HARD_REGNO_MODE_OK (regno + n, m1) == 0
TEST_HARD_REG_BIT (reg_class_contents[class], regno) == 1
TEST_HARD_REG_BIT (reg_class_contents[class], regno + n) == 0
So, the algorithm in find_valid_class selects EVEN_REGS for a
mode == Pmode and n==1.
thanks, Marco Altieri
More information about the Gcc-bugs
mailing list