[LLVMdev] subregisters, def-kill

Jakob Stoklund Olesen stoklund at 2pi.dk
Fri May 20 10:28:37 PDT 2011


On May 20, 2011, at 10:09 AM, Jonas Paulsson wrote:

> If I write
> 
> %reg16506<def> = INSERT_SUBREG %reg16506, %reg16445, hi16;   #1
> %reg16506<def> = INSERT_SUBREG %reg16506, %reg16468, lo16;   #2
> store %reg16506                                                                                    #3

This is still not SSA, you need something like:

a = IMPLICIT_DEF
b = INSERT_SUBREG a, foo, hi16
c = INSERT_SUBREG c, bar, lo16

But as you correctly observe:

> it will not coalesce, as  

Which is why we added REG_SEQUENCE:

> But if I write
> 
> %reg16507<def> = COPY %reg16445;
> %reg16508<def> = COPY %reg16468;
> %reg16506<def> = REG_SEQUENCE %reg16507, hi16, %reg16508, lo16;
> %reg16509<def> = st_2_1_postMod %reg16506, %reg16441, %reg16454, pred:20, pred:%CCReg;
> 
> then, there is not an erroneous live-range that interferes, so it coalesces.

Yes, this is correct.

> I suppose this means that the first version with INSERT_SUBREG's is breaking the SSA-form? Or am I doing it wrong?

You were doing it wrong, but even when done correctly, chained INSERT_SUBREGs don't coalesce. That is really a coalescer bug.

> 
> In a similar case, the coalescer will not join the %reg16478 into %reg16511, although it makes perfect sense [after SimpleRegisterCoalescer]:
> 
> 836L    %reg16511:hi16<def> = COPY %reg16473:lo16<kill>, %reg16511<imp-def>; 
> 844L    %reg16511:lo16<def> = COPY %reg16478:lo16<kill>; 
> 852L    %r4<def,dead> = st_postMod %reg16511<kill>, %r4
> ...
> 844L    %reg16511:lo16<def> = COPY %reg16478:lo16<kill>; Accum:%reg16511,16478
>         Considering merging %reg16478 with reg%16511 to Accum
>         RHS = %reg16478,0.000000e+00 = [804d,844d:0)  0 at 804d
>         LHS = %reg16511,0.000000e+00 = [836d,844d:1)[844d,852d:0)  0 at 844d 1 at 836d
>     Interference!
> 
> It seems that there is a Live range from the first COPY  to the store, which interferes with the second COPY, which should have been coalesced. I find it worrisome that LLVM is not recognizing sub-registers apart from the super register. I would like to work with subregisters so as to define subregister liveness, but I find that LLVM is only keeping live information for the super-register, regardless of which subreg was defined. How could I overcome this?

I am planning to fix this, but it is not an easy problem. The REG_SEQUENCE instruction provides a workaround.

/jakob

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110520/938a277d/attachment.html>


More information about the llvm-dev mailing list