[TableGen] GlobalISelEmitter crashes: "Failed to lookup instruction"

Hi!

I run into a crash of llvm-tblgen with the GlobalISelEmitter. A pattern which has an intrinsic using a target constant as source, and an instruction with an immediate as replacement, triggers it. Examples in the LLVM tree are:

From Hexagon target:

def: Pat<(int_hexagon_A2_addi IntRegs:$Rs, timm:$s16),
         (A2_addi IntRegs:$Rs, imm:$s16)>;

From SystemZ target:

  def : Pat<(int_s390_vcfn VR128:$x, imm32zx4_timm:$m),
            (VCFN VR128:$x, 1, imm32zx4:$m)>;

In these cases, the llvm_unreachable in CopyConstantAsImmRenderer::emitRenderOpcodes() is reached, printing the message Failed to lookup instruction.

Hints how to fix this are welcome.

Regards,
Kai