[llvm-dev] Reg units for unaddressable register parts?

Matthias Braun via llvm-dev llvm-dev at lists.llvm.org
Wed Sep 28 11:45:01 PDT 2016

> On Sep 28, 2016, at 11:20 AM, Quentin Colombet via llvm-dev <llvm-dev at lists.llvm.org> wrote:
>> On Sep 28, 2016, at 10:52 AM, Krzysztof Parzyszek via llvm-dev <llvm-dev at lists.llvm.org> wrote:
>> On X86, the registers AX, EAX and RAX all share the exact same register units. In terms of units, there is no difference between these registers. This makes register units insufficient to track liveness, since live AX does not imply live EAX.
> That is exactly the intent.
> If AX is live, you don’t want another value to use EAX or RAX.

You can track liveness but you may have to make conservative assumptions like the whole RAX register being live even though it may only be AL+AH in reality. Usually that is good enough (it is for the register allocator!). There are very few cases where the difference matters. The only ones I can think of right now are ABIs corner cases (see below [1]) and X86FixupBWInsts. In general however we should be careful not to produce unnecessary/extra regunits, that will just increase memory consumption and slow down the compiler. Having said that I wouldn't mind producing enough extra regunits to be able to express clobber masks in register units. Generally producing regunits for all unaddressable parts is not a good idea IMO.

[1] ABIs:
x86 / win64 calling convention preserves a bunch of XMM registers but not the corresponding YMM registers => the lower 128bit are saved, the upper 128 bit of the YMM register are clobbered.
AArch64: Preserves the 64bit of several float register (Dxx) but not the upper parts (Qxx).
This forces us to express the clobbered register masks in terms of physreg numbers and not register unit which is unfortunate as we are usually better of expressing liveness in registser units.

- Matthias

More information about the llvm-dev mailing list