[RISCV] Add isel patterns for ineg+setge/le/uge/ule.
authorCraig Topper <craig.topper@sifive.com>
Mon, 18 Jul 2022 16:10:53 +0000 (09:10 -0700)
committerCraig Topper <craig.topper@sifive.com>
Mon, 18 Jul 2022 16:55:01 +0000 (09:55 -0700)
commit7c0b9b379b0e36ec1ed76ab5a4386e80dafd53fc
treeca33878bc02ae9914e865b54f9d02c4ef2d71790
parent1586075a00bfae764db60ad23a2b58cc1007061d
[RISCV] Add isel patterns for ineg+setge/le/uge/ule.

setge/le/uge/ule selected by themselves require an xori with 1.
If we're negating the setcc, we can fold the xori with the neg
to create an addi with -1.

This works because xori X, 1 is equivalent to 1 - X if X is either
0 or 1. So we're doing -(1 - X) which is X-1 or X+-1.

This improves the code for selecting between 0 and -1 based on a
condition for some conditions.

Reviewed By: asb

Differential Revision: https://reviews.llvm.org/D129957
llvm/lib/Target/RISCV/RISCVInstrInfo.td
llvm/test/CodeGen/RISCV/select-const.ll