[llvm-branch-commits] [llvm] 401d716 - MIPS: Fix unsigned compare with zero in MipsSEInstrInfo::copyPhysReg (#179866)

Cullen Rhodes via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Feb 9 01:51:12 PST 2026


Author: YunQiang Su
Date: 2026-02-09T09:51:04Z
New Revision: 401d7166ed107bf770b3ba424bdfcd4a39a8742c

URL: https://github.com/llvm/llvm-project/commit/401d7166ed107bf770b3ba424bdfcd4a39a8742c
DIFF: https://github.com/llvm/llvm-project/commit/401d7166ed107bf770b3ba424bdfcd4a39a8742c.diff

LOG: MIPS: Fix unsigned compare with zero in MipsSEInstrInfo::copyPhysReg (#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)
```

(cherry picked from commit 209ff8bf06dd12becd79c1ebb01612c021e19f6c)

Added: 
    

Modified: 
    llvm/lib/Target/Mips/MipsSEInstrInfo.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/Mips/MipsSEInstrInfo.cpp b/llvm/lib/Target/Mips/MipsSEInstrInfo.cpp
index 4a92b1ffc4cf9..90f2996e7f93e 100644
--- a/llvm/lib/Target/Mips/MipsSEInstrInfo.cpp
+++ b/llvm/lib/Target/Mips/MipsSEInstrInfo.cpp
@@ -242,7 +242,7 @@ void MipsSEInstrInfo::copyPhysReg(MachineBasicBlock &MBB,
       Opc = Mips::FMOV_D64;
       unsigned DestRegOff = DestReg.id() - Mips::D0_64;
       unsigned SrcRegOff = SrcReg.id() - Mips::F0;
-      if (SrcRegOff == DestRegOff && SrcRegOff >= 0 && SrcRegOff <= 31)
+      if (SrcRegOff == DestRegOff && SrcRegOff <= 31)
         return;
     }
   } else if (Opc == 0 && Mips::FGR32RegClass.contains(DestReg) &&
@@ -253,7 +253,7 @@ void MipsSEInstrInfo::copyPhysReg(MachineBasicBlock &MBB,
       Opc = Mips::FMOV_D32;
       unsigned DestRegOff = DestReg.id() - Mips::F0;
       unsigned SrcRegOff = SrcReg.id() - Mips::D0_64;
-      if (SrcRegOff == DestRegOff && SrcRegOff >= 0 && SrcRegOff <= 31)
+      if (SrcRegOff == DestRegOff && SrcRegOff <= 31)
         return;
     }
   }


        


More information about the llvm-branch-commits mailing list