[llvm] [RISCV][NFC] Simplify Imm range checks (PR #170497)

Piotr Fusik via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 3 10:32:22 PST 2025


================
@@ -2898,13 +2898,13 @@ bool RISCVInstrInfo::verifyInstruction(const MachineInstr &MI,
           Ok = isShiftedUInt<4, 1>(Imm);
           break;
         case RISCVOp::OPERAND_UIMM5_NONZERO:
-          Ok = isUInt<5>(Imm) && (Imm != 0);
+          Ok = Imm >= 1 && Imm <= 31;
----------------
pfusik wrote:

Checking the lower bound once is easier to read for me.
But that's not a strong preference. How about I revert the `isXXX && oneCond` cases to leave only the `plus1`/`minus1` changed?

https://github.com/llvm/llvm-project/pull/170497


More information about the llvm-commits mailing list