Skip to content

Commit c188829

Browse files
committed
As suggested in code review, add additional isReg checks
Not clear these are needed, but it is consistent.
1 parent c700bc4 commit c188829

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

llvm/lib/Target/RISCV/RISCVInstrInfo.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1651,9 +1651,11 @@ RISCVInstrInfo::isCopyInstrImpl(const MachineInstr &MI) const {
16511651
default:
16521652
break;
16531653
case RISCV::ADD:
1654-
if (MI.getOperand(1).isReg() && MI.getOperand(1).getReg() == RISCV::X0)
1654+
if (MI.getOperand(1).isReg() && MI.getOperand(1).getReg() == RISCV::X0 &&
1655+
MI.getOperand(2).isReg())
16551656
return DestSourcePair{MI.getOperand(0), MI.getOperand(2)};
1656-
if (MI.getOperand(2).isReg() && MI.getOperand(2).getReg() == RISCV::X0)
1657+
if (MI.getOperand(2).isReg() && MI.getOperand(2).getReg() == RISCV::X0 &&
1658+
MI.getOperand(1).isReg())
16571659
return DestSourcePair{MI.getOperand(0), MI.getOperand(1)};
16581660
break;
16591661
case RISCV::ADDI:

0 commit comments

Comments
 (0)