Paul Koning schrieb:
On Feb 24, 2011, at 12:46 PM, Eric Botcazou wrote:


Maybe the misunderstanding occurs when the mode of the subreg is
 less than word_size?  It would certainly make sense that a
subreg write of less than word_size leaves the bits undefined.

ie, if word_size is SImode and we had a write to

(subreg:HI (reg:SI) 0)

Then the upper bits are left undefined.


Contrast that to the same RTL, but word_size is HImode

(subreg:HI (reg:SI) 0)

Would leave the upper bits untouched.

That's the conventional wisdom I think. Sub-word and word-sized subregs don't behave the same, in particular when they are on the LHS of an assignment.


That's certainly what the manual says.


I still don't understand.

The manual says:

http://gcc.gnu.org/onlinedocs/gccint/Regs-and-Memory.html#Regs-and-Memory

When storing to a normal subreg that is smaller than a word, the other bits of the referenced word are usually left in an undefined state. This laxity makes it easier to generate efficient code for such instructions. To represent an instruction that preserves all the
bits outside of those in the subreg, use strict_low_part or
zero_extract around the subreg.

What does "word" mean here? Is it a 32-bit entity or is it according to word_mode which is QImode for avr?

In the latter case, all code generated by subreg lowering and RTL lowering (which expands DI operation to bulk of (set (subreg:QI (DI)) as avr backend does not have DI-insns) is fine and I will have to dig in IRA for PR45291, PR46779 and maybe others.

In the first case all code that RTL lowering produces for 64-bit stuff would be incorrect which is hard to imagine...

Some lines after that, internals give an example for HI subregs of PSI:

> If "UNITS_PER_WORD <= 2" then these two subregs:
>          (subreg:HI (reg:PSI 0) 0)
>          (subreg:HI (reg:PSI 0) 2)
> represent independent 2-byte accesses that together span the whole of
> "(reg:PSI 0)". Storing to the first subreg does not affect the value
> of the second, and vice versa.

So the same should be true for QI-subregs of scalar modes if UNITS_PER_WORT = 1. Right?

Georg-Johann

Reply via email to