[LLVMdev] LLVM: MachineCopyPropagation.cpp

Jonas Paulsson jonas.paulsson at ericsson.com
Thu Feb 16 06:30:26 PST 2012


Hi,

I have the following code:

  %a1<def> = COPY %a0<kill>
  ...
  %a0h<def> = COPY %a1l

, as input to MachineCopyPropagation.

The second copy is illegally erased! This is wrong, because it is the low part of a1 that is copied to the high part of a0.

At a first glance, it seems that

 if (!ReservedRegs.test(Def) &&
     (!ReservedRegs.test(Src) || NoInterveningSideEffect(CopyMI, MI)) &&
       (SrcSrc == Def || TRI->isSubRegister(SrcSrc, Def))) {
        ...
        (erase COPY)

, should be extended to

...
      (SrcSrc == Def || (TRI->isSubRegister(SrcSrc, Def) && isMatchingSubRegIdx(%a0, %a0h, %a1, %a1l)))) {

, where isMatchingSubRegIdx (or whatever) should make sure that this type of subreg motion is not missed.

Or is there something else that I've missed, that would avoid the problem?

/Jonas


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


More information about the llvm-dev mailing list