middle-end/5100: Wrong register class selected by find_valid_class

Marco Altieri maltieri@nergal.it
Mon Apr 15 06:36:00 GMT 2002


The following reply was made to PR middle-end/5100; it has been noted by GNATS.

From: "Marco Altieri" <maltieri@nergal.it>
To: <rth@gcc.gnu.org>, <gcc-bugs@gcc.gnu.org>, <gcc-prs@gcc.gnu.org>,
   <lonardo@nergal.it>, <maltieri@nergal.it>, <nobody@gcc.gnu.org>,
   <gcc-gnats@gcc.gnu.org>
Cc:  
Subject: Re: middle-end/5100: Wrong register class selected by find_valid_class
Date: Mon, 15 Apr 2002 15:32:51 +0200

 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-prs mailing list