This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

GCC question.


I have a question to ask about an example of the combination phase on some RTL.
The target has 64-bit integer registers and I wish to perform zero extension
from HI to DI using an "and" operation with a bit-mask of 0xffff. However, the
current method of zero extension seems to benefit from an extra combination
under certain circumstances which the masking version seems to miss.

Given the following RTL (paraphrasing for brevity):
	:	:	:	:	:
(set (reg:SI 168) (subreg:SI (reg/v:DI 160) 0)) (expr_list:REG_DEAD (reg/v:DI
160)

(set (reg:SI 167) (plus:SI (reg:SI 168) (const_int 1 [0x1]))
(expr_list:REG_DEAD (reg:SI 168)(expr_list:REG_EQUAL (plus:SI (subreg:SI
(reg/v:DI 160) 0) (const_int 1 [0x1])

(set (reg/v:DI 160) (zero_extend:DI (subreg:HI (reg:SI 167) 0)))
(expr_list:REG_DEAD (reg:SI 167)
	:	:	:	:	:

The combiner spots that it can perform the "plus" directly in DI mode because
the top 32 (actually 48) bits are going to be thrown away, then remove the
first subreg set, which saves a move instruction as it turns out.
However, given *functionally* equivalent RTL:

	:	:	:	:	:
(set (reg:SI 168) (subreg:SI (reg/v:DI 160) 0)) (expr_list:REG_DEAD (reg/v:DI
160)

(set (reg:SI 167) (plus:SI (reg:SI 168) (const_int 1 [0x1]))
(expr_list:REG_DEAD (reg:SI 168)(expr_list:REG_EQUAL (plus:SI (subreg:SI
(reg/v:DI 160) 0) (const_int 1 [0x1])

(set (reg/v:DI 160) (and:DI (subreg:HI (reg:SI 167) 0) (reg:DI 170))
(expr_list:REG_DEAD (reg_SI 167) (expr_list:REG_EQUAL (zero_extend:DI
(subreg:HI (reg:SI 167) 0)
	:	:	:	:	:

The combiner doesn't spot the optimisation. The reg:DI 170 contains the 0xffff,
which the compiler should know as it just put it there! Also, the REG_EQUAL
note shows that the discarding of the top 48 bits could also be considered.

So my question is:
i)  What is stopping the combination in the second case?
ii) Is there in fact some standard way of doing this masking operation which
would not incur this problem?

Many thanks,
	- Steve.

-- 
  			   - Stephen Jones -
	  ST Microelectronics, Almondsbury, Bristol, United Kingdom.
		   .(2430 Aztec Park West -- Software Dept).
			Tel/VM (+44)(1454) 462388.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]