LLVM: MachineCopyPropagation.cpp

Hi,

I have the following code:

%a1 = COPY %a0

%a0h = 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

Hello Jonas,

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.

copyprop is known to be buggy (see PR11940 as an example). So, it'd
advised to use -disable-copyprop by default for now.