[LLVMdev] MachineOperand: Subreg defines and the Undef flag (original) (raw)

Jakob Stoklund Olesen stoklund at 2pi.dk
Thu Jul 5 18:48:46 PDT 2012


On Jul 5, 2012, at 6:01 PM, "Pranav Bhandarkar" <pranavb at codeaurora.org> wrote:

Hi Jakob,

NewMI1:: Vreg1 = 0 ; Vreg1 and Vreg2 are 32 bit virt. regs. NewMI2:: Vreg2 = COPY C:losubreg. NewMI3:: B= REGSEQUENCE<Vreg1, hisubreg, Vreg2, losubreg> ; B is a 64 bit virt reg. I used this approach and it worked find until I hit, what I believe is, a bug in the register coalescer. When the register coalescer cannot trivially coalesce a copy, say C,, it calls AdjustCopiesBackFrom. In this function, we try to see if have this situation. A3 = B0 ..... ..... B1 = A3 <--The copy C_ _And if so, we check if we can merge the two ranges of B into a single range._ _However, this is not safe if A3 is a subreg define while A3 is not a subreg_ _use._ _For instance, consider this code (part of a single block loop)._ _MI1:: %vreg7:subregloreg<def,undef>, %vreg30 = POSTLDriuh %vreg30, 2, // Post Inc. Load. Vreg7 is a 64bit reg. MI2:: %vreg7:subreghireg = COPY %vreg32:subreghireg // This is the A3 = B0 above. MI3:: %vreg31 = ADDrr %vreg31, %vreg32:subregloreg // Use the lo subreg that was setup in MI1: .... .... MI4:: %vreg32 = COPY %vreg7; //Not trivial because 7 is not killed. This is the Copy C i.e. B1=A3. .... MI5:: Conditional jump back to start of the block. The coalesce coalesces the copy withouth realizing that the instruction that defined the source of the copy was a copy instruction that only copied a subreg not the whole register. In the event, we lose the lower subreg. Let me know If I am missing something.

That sounds like a bug, probably adjustCopiesBackFrom needs to check ACopyMI->isFullCopy().

Do you have a test case for this?

/jakob



More information about the llvm-dev mailing list