This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: middle-end/5100: Wrong register class selected by find_valid_class
- From: "Marco Altieri" <maltieri at nergal dot it>
- To: <rth at gcc dot gnu dot org>, <gcc-bugs at gcc dot gnu dot org>, <gcc-prs at gcc dot gnu dot org>, <lonardo at nergal dot it>, <maltieri at nergal dot it>, <nobody at gcc dot gnu dot org>, <gcc-gnats at gcc dot gnu dot org>
- Date: Mon, 15 Apr 2002 15:32:51 +0200
- Subject: Re: middle-end/5100: Wrong register class selected by find_valid_class
- References: <20020404122730.1886.qmail@sources.redhat.com>
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