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
Differential D137949
[RISCV] Branchless lowering for (select (x < 0), TrueConstant, FalseConstant) and (select (x >= 0), TrueConstant, FalseConstant) liaolucy on Nov 14 2022, 7:20 AM. Authored by
Details This patch reduces the number of unpredictable branches (select (x < 0), y, z) -> x >> (XLEN - 1) & (y - z) + z
Diff Detail
Event Timeline
Comment Actions Address Craig.topper's comments Add (select (x >= 0), y, z) -> x >> (XLEN - 1) & (z - y) + y Add (select (x > -1), y, z) to the testcase
Comment Actions Update std::swap(TrueSImm, FalseSImm) to std::swap(TrueV, FalseV), thanks.
|
It looks like we can avoid the not here by swapping the operands.