Skip to content

Commit 209ff8b

Browse files
authored
MIPS: Fix unsigned compare with zero in MipsSEInstrInfo::copyPhysReg (llvm#179866)
SrcRegOff >= 0 is not needed at all for unsigned. This fixes the warning: ``` llvm/lib/Target/Mips/MipsSEInstrInfo.cpp: In member function ‘virtual void llvm::MipsSEInstrInfo::copyPhysReg(llvm::MachineBasicBlock&, llvm::MachineBasicBlock::iterator, const llvm::DebugLoc&, llvm::Register, llvm::Register, bool, bool, bool) const’: llvm/lib/Target/Mips/MipsSEInstrInfo.cpp:245:48: warning: comparison of unsigned expression in ‘>= 0’ is always true [-Wtype-limits] 245 | if (SrcRegOff == DestRegOff && SrcRegOff >= 0 && SrcRegOff <= 31) | ~~~~~~~~~~^~~~ llvm/lib/Target/Mips/MipsSEInstrInfo.cpp:256:48: warning: comparison of unsigned expression in ‘>= 0’ is always true [-Wtype-limits] 256 | if (SrcRegOff == DestRegOff && SrcRegOff >= 0 && SrcRegOff <= 31) ```
1 parent 8949c6d commit 209ff8b

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

llvm/lib/Target/Mips/MipsSEInstrInfo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ void MipsSEInstrInfo::copyPhysReg(MachineBasicBlock &MBB,
242242
Opc = Mips::FMOV_D64;
243243
unsigned DestRegOff = DestReg.id() - Mips::D0_64;
244244
unsigned SrcRegOff = SrcReg.id() - Mips::F0;
245-
if (SrcRegOff == DestRegOff && SrcRegOff >= 0 && SrcRegOff <= 31)
245+
if (SrcRegOff == DestRegOff && SrcRegOff <= 31)
246246
return;
247247
}
248248
} else if (Opc == 0 && Mips::FGR32RegClass.contains(DestReg) &&
@@ -253,7 +253,7 @@ void MipsSEInstrInfo::copyPhysReg(MachineBasicBlock &MBB,
253253
Opc = Mips::FMOV_D32;
254254
unsigned DestRegOff = DestReg.id() - Mips::F0;
255255
unsigned SrcRegOff = SrcReg.id() - Mips::D0_64;
256-
if (SrcRegOff == DestRegOff && SrcRegOff >= 0 && SrcRegOff <= 31)
256+
if (SrcRegOff == DestRegOff && SrcRegOff <= 31)
257257
return;
258258
}
259259
}

0 commit comments

Comments
 (0)