[RISCV] Branchless lowering for (select (x < 0), TrueConstant, FalseConstant) and...
authorLiaoChunyu <chunyu@iscas.ac.cn>
Thu, 17 Nov 2022 09:15:27 +0000 (17:15 +0800)
committerLiaoChunyu <chunyu@iscas.ac.cn>
Fri, 25 Nov 2022 12:18:30 +0000 (20:18 +0800)
commitaa14f002d57b8b3cf30f07c782d2d93f358e51fd
tree303d5121eee9617f342211e6bd3640432acaf8fc
parent9d5e82e75c61df1a79e337770c1d54d83b33d96a
[RISCV] Branchless lowering for (select (x < 0), TrueConstant, FalseConstant) and (select (x >= 0), TrueConstant, FalseConstant)

This patch reduces the number of unpredictable branches

(select (x < 0), y, z)  -> x >> (XLEN - 1) & (y - z) + z
(select (x >= 0), y, z) -> x >> (XLEN - 1) & (z - y) + y

Reviewed By: craig.topper, reames

Differential Revision: https://reviews.llvm.org/D137949
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/test/CodeGen/RISCV/select-const.ll