Resend: assertion in MachineCopyPropagation::isNopCopy

Hi, anyone know anything about copy propagation? Matthias, I see this was your code originally? Was there some assumptions you made?

I'm hitting an assertion in MachineCopyPropagation::isNopCopy:

if (Src == PreviousSrc) {
   assert(Def == PreviousDef);
   return true;
}

This code compares two COPY instruction to see whether they are effectively "the same". The assert assumes that, if the sources are the same register then the destinations must be as well.
My instructions look like this, however:

   %V2<def> = COPY %V6
   %V6<def> = COPY %V2_LO

(isNopCopy is called with src and dest of the first instruction switched.)
So dst2 == src1 but src2 is a subregister of dst1.
Is there some assumption that size(src) == size(dst)?
This second COPY, with size(src) != size(dst) was generated in InstrEmitter::EmitSubregNode at

// Create the extract_subreg machine instruction.

So it's not out-of-tree code.
Am I missing something or should the assert condition be part of the "if" condition instead?
Thanks,

Hi, anyone know anything about copy propagation? Matthias, I see this was your code originally? Was there some assumptions you made?

I'm hitting an assertion in MachineCopyPropagation::isNopCopy:

if (Src == PreviousSrc) {
assert(Def == PreviousDef);
return true;
}

This code compares two COPY instruction to see whether they are effectively "the same". The assert assumes that, if the sources are the same register then the destinations must be as well.
My instructions look like this, however:

%V2<def> = COPY %V6
%V6<def> = COPY %V2_LO

(isNopCopy is called with src and dest of the first instruction switched.)
So dst2 == src1 but src2 is a subregister of dst1.
Is there some assumption that size(src) == size(dst)?

Yes COPY can only be used for registers of the same size; it won't automatically select a matching subregister but must be constructed with the correct subregister upfront (V2 instead of V2_LO in your case I assume?). Unfortunately the machine verifier currently has no way to catch/assert on this sort of error so it may stay undetected throughout large parts of the pipeline.

This second COPY, with size(src) != size(dst) was generated in InstrEmitter::EmitSubregNode at

I would suspect the problem here. But would need to know more to say for sure (like how your register hierarchies look like, how the SelectionDAG node and the generated MI instruction looks).

- Matthias