diff --git a/llvm/lib/Target/RISCV/RISCVMergeBaseOffset.cpp b/llvm/lib/Target/RISCV/RISCVMergeBaseOffset.cpp --- a/llvm/lib/Target/RISCV/RISCVMergeBaseOffset.cpp +++ b/llvm/lib/Target/RISCV/RISCVMergeBaseOffset.cpp @@ -140,6 +140,8 @@ if (Hi.getOpcode() != RISCV::AUIPC) Lo.getOperand(2).setOffset(Offset); // Delete the tail instruction. + MRI->constrainRegClass(Lo.getOperand(0).getReg(), + MRI->getRegClass(Tail.getOperand(0).getReg())); MRI->replaceRegWith(Tail.getOperand(0).getReg(), Lo.getOperand(0).getReg()); Tail.eraseFromParent(); LLVM_DEBUG(dbgs() << " Merged offset " << Offset << " into base.\n"