[RISCV] Fold (select setcc, setcc, setcc) into and/or instructions
authorYingwei Zheng <dtcxzyw2333@gmail.com>
Fri, 12 May 2023 07:06:58 +0000 (15:06 +0800)
committerYingwei Zheng <dtcxzyw2333@gmail.com>
Fri, 12 May 2023 07:06:58 +0000 (15:06 +0800)
commitaf161ffc7fdd8a258c571fd50a4642011cf184de
tree54186647d14d7a7c8e2bc0814eecf7251e2abca4
parent478739b2d12cf59bdd4394fd7ebe681043dd135b
[RISCV] Fold (select setcc, setcc, setcc) into and/or instructions

This patch folds `(select setcc, setcc, setcc)` into and/or instructions when truev/falsev is equal to or the inverse of condv.

(select x, x, y) -> x | y https://alive2.llvm.org/ce/z/36Ud3Z
(select !x, x, y) -> x & y https://alive2.llvm.org/ce/z/mYYoGF
(select x, y, x) -> x & y https://alive2.llvm.org/ce/z/MAZ--X
(select !x, y, x) -> x | y https://alive2.llvm.org/ce/z/ct7By5

It is the follow-up improvement of D150177, which optimizes the code of signed truncation check patterns without Zbb.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D150286
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/test/CodeGen/RISCV/forced-atomics.ll
llvm/test/CodeGen/RISCV/fpclamptosat.ll
llvm/test/CodeGen/RISCV/iabs.ll
llvm/test/CodeGen/RISCV/lack-of-signed-truncation-check.ll
llvm/test/CodeGen/RISCV/xaluo.ll