Messages in this thread | | | From | Uros Bizjak <> | Date | Tue, 13 Oct 2020 10:00:45 +0200 | Subject | Re: [GIT PULL] x86/asm updates for v5.10 |
| |
On Mon, Oct 12, 2020 at 10:57 PM Linus Torvalds <torvalds@linux-foundation.org> wrote: > > On Mon, Oct 12, 2020 at 1:22 PM Uros Bizjak <ubizjak@gmail.com> wrote: > > > > No, this fact is not documented, although there are close to zero > > chances it will ever change. High registers are independent from their > > 8bit lowparts, but they still clobber corresponding 16bit, 32bit and > > 64bit representations. I guess this limitation is so severe that the > > compiler writers will be more than happy to document that %ah and %al > > can't be independent. > > Ok, if we can get that agreed upon (and the clang people too), then I > have no concerns about the patch.
The GCC's development documentation says:
--cut here-- When storing to a normal 'subreg' that is smaller than a block, the other bits of the referenced block 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'. --cut here--
REG is divided into individually-addressable blocks in which each block has:
REGMODE_NATURAL_SIZE (M2)
bytes. Usually the value is 'UNITS_PER_WORD'; that is, most targets usually treat each word of a register as being independently addressable.
The 'block' is 32bits for i386 or 64bits for x86_64. When asm is writing to %al, this effectively means that other bits of a register are left in an undefined state. Please note that 'strict_low_part' and 'zero_extract' are internal representations, not available in asm statements.
> Just so that we don't have any nasty surprises in the future where > some clever compiler change ends up breaking this (very rare) > exception case.
IMO the above documents that write to a partial register clobbers the entire register.
Uros.
| |