aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/RISCV/RISCVMacroFusion.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Target/RISCV/RISCVMacroFusion.cpp')
-rw-r--r--llvm/lib/Target/RISCV/RISCVMacroFusion.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/lib/Target/RISCV/RISCVMacroFusion.cpp b/llvm/lib/Target/RISCV/RISCVMacroFusion.cpp
index 3b9177bc1635..232f202f1815 100644
--- a/llvm/lib/Target/RISCV/RISCVMacroFusion.cpp
+++ b/llvm/lib/Target/RISCV/RISCVMacroFusion.cpp
@@ -45,9 +45,15 @@ static bool isLUIADDI(const MachineInstr *FirstMI,
if (SecondMI.getOperand(1).getReg() != FirstDest)
return false;
+ // If the input is virtual make sure this is the only user.
+ if (FirstDest.isVirtual()) {
+ auto &MRI = SecondMI.getMF()->getRegInfo();
+ return MRI.hasOneNonDBGUse(FirstDest);
+ }
+
// If the FirstMI destination is non-virtual, it should match the SecondMI
// destination.
- return FirstDest.isVirtual() || SecondMI.getOperand(0).getReg() == FirstDest;
+ return SecondMI.getOperand(0).getReg() == FirstDest;
}
static bool shouldScheduleAdjacent(const TargetInstrInfo &TII,