Index: llvm/lib/Target/RISCV/RISCVInstrInfo.td =================================================================== --- llvm/lib/Target/RISCV/RISCVInstrInfo.td +++ llvm/lib/Target/RISCV/RISCVInstrInfo.td @@ -998,6 +998,12 @@ def : Pat<(brcond (XLenVT (xor GPR:$cond, 1)), bb:$imm12), (BEQ GPR:$cond, X0, bb:$imm12)>; +// Lower (a > -1) to (a >= 0) and (a < 1) to (0 >= a). +def : Pat<(brcond (XLenVT (setlt XLenVT:$lhs, 1)), bb:$dst), + (BGE X0, XLenVT:$lhs, bb:$dst)>; +def : Pat<(brcond (XLenVT (setgt XLenVT:$lhs, -1)), bb:$dst), + (BGE XLenVT:$lhs, X0, bb:$dst)>; + let isBarrier = 1, isBranch = 1, isTerminator = 1 in def PseudoBR : Pseudo<(outs), (ins simm21_lsb0_jal:$imm20), [(br bb:$imm20)]>, PseudoInstExpansion<(JAL X0, simm21_lsb0_jal:$imm20)>;