[LLVMdev] wide memory accesses

Jonas Paulsson jnspaulsson at hotmail.com
Mon May 9 09:00:21 PDT 2011





Hi,

I am trying to take 16 bit memory reads and combine them to a single 32 bit read. I am having trouble to make the code simply read 32 bytes and the use the subregisters accordingly, without unnecessary copying.

I have tried two techniques, in the MachineFunction:

1. replace the MachineOperands in the users of the data with the new register/subregister index. This yields an assert failure during VirtRegRewriter, in substPhysReg: "Invalid SubReg for physical register", after the Two-address rewrote this:

%reg16445<def> = add %reg16507:hi16, %reg16510:hi16 ; 32bit:16507,16510, 16bit: 16445  
  prepend:    %reg16445<def> = COPY %reg16507; 
  rewrite to:    %reg16445<def> = addh_1_8 %reg16445:hi16, %reg16510:hi16

In my eyes, there should not have been a subreg 'hi16' for the 16445 reg - this reg is 16 bits. I would have wished that the 16507:hi16 be interpreted as the corresponding subregister, and thus generated in the COPY with a :hi16. It is all right that the 16445 is of 16 bits, this is correct, but then it is used incorrectly with a :hi16 subregister value ?? Any ideas?

I am trying to use register classes as follows: I have one register class for 32 bit registers, and another one for the subregisters of 16 bits. Intuitively, I would like to use instructions with operands of the 16 bit register class, and then be able to use 32 bit registers with a subregister index. Is this possible, or need I make a new register class where all these are included in a blended fashion: 16/32 bits, and use this instead for the instruction?

I have defined the 16 bit registers as subregs to the 32 bits. I have also defined subregclasses, as per  let SubRegClasses =... 

2. Insert COPY's, but these would not get coalesced away, so instead of saving instructions I ended up with one load and two moves...:-( How could I get the wide load to simply be used intelligently by COPYing to the old virtual registers?

I would appreciate any advice on how to get good code with a SIMD combinations as in the example above! What would the general layout of register classes typically look like? I imagine the best approach is the first one, where the operands simply get updated, without any COPY's introduced.

Thanks,

Jonas





 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110509/44727d80/attachment.html>


More information about the llvm-dev mailing list