diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp --- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp +++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp @@ -3633,10 +3633,9 @@ if (isa(RHS)) { int64_t Imm = cast(RHS)->getSExtValue(); if (Imm != 0 && isInt<12>((uint64_t)Imm + 1)) { - // If this is an unsigned compare and the constant is -1, incrementing - // the constant would change behavior. The result should be false. - if (CCVal == ISD::SETUGT && Imm == -1) - return DAG.getConstant(0, DL, VT); + // X > -1 should have been replaced with false. + assert((CCVal != ISD::SETUGT || Imm != -1) && + "Missing canonicalization"); // Using getSetCCSwappedOperands will convert SET(U)GT->SET(U)LT. CCVal = ISD::getSetCCSwappedOperands(CCVal); SDValue SetCC = DAG.getSetCC(