[RISCV] Optimize x <s -1 ? x : -1. Improve x >u 1 ? x : 1.
authorCraig Topper <craig.topper@sifive.com>
Sun, 21 Aug 2022 18:46:05 +0000 (11:46 -0700)
committerCraig Topper <craig.topper@sifive.com>
Sun, 21 Aug 2022 18:48:28 +0000 (11:48 -0700)
commit1a042dd6ed2108f67f567fcd13a9737f946e6522
tree65cd401d74583288ee03c6fcbd5859820b15e780
parenta6c3ccd476d43305fc91f56c8066f913110ce078
[RISCV] Optimize x <s -1 ? x : -1. Improve x >u 1 ? x : 1.

Similar to D132211, we can optimize x <s -1 ? x : -1 -> x <s 0 ? x : -1

Also improve the unsigned case from D132211 to use x != 0 which
will give a bnez instruction which might be compressible.

Differential Revision: https://reviews.llvm.org/D132252
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/test/CodeGen/RISCV/forced-atomics.ll
llvm/test/CodeGen/RISCV/min-max.ll