diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp b/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp --- a/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp +++ b/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp @@ -1659,6 +1659,9 @@ bool Mul2IsKill = Mul2.isKill(); bool AddendIsKill = Addend.isKill(); + // We need to clear kill flags since we may be extending the live range past + // a kill. If the mul had kill flags, we can preserve those since we know + // where the previous range stopped. MRI.clearKillFlags(Mul1.getReg()); MRI.clearKillFlags(Mul2.getReg()); diff --git a/llvm/test/CodeGen/RISCV/machine-combiner.mir b/llvm/test/CodeGen/RISCV/machine-combiner.mir --- a/llvm/test/CodeGen/RISCV/machine-combiner.mir +++ b/llvm/test/CodeGen/RISCV/machine-combiner.mir @@ -1,5 +1,5 @@ # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 3 -# RUN: llc %s -mtriple=riscv64 -mattr=+f -run-pass=machine-combiner \ +# RUN: llc %s -o - -mtriple=riscv64 -mattr=+f -run-pass=machine-combiner \ # RUN: -verify-machineinstrs | FileCheck %s --- |