[PATCH] D134881: [RISCV] Branchless lowering for select (and (x , 0x1) == 0), y, (z ^ y) ) and select (and (x , 0x1) == 0), y, (z | y) )
Philip Reames via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 29 07:24:39 PDT 2022
reames created this revision.
reames added reviewers: craig.topper, asb, kito-cheng, frasercrmck.
Herald added subscribers: sunshaoce, VincentWu, StephenFan, vkmr, evandro, luismarques, apazos, sameer.abuasal, pengfei, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, niosHD, sabuasal, bollu, simoncook, johnrusso, rbar, hiraditya, arichardson, mcrosier.
Herald added a project: All.
reames requested review of this revision.
Herald added subscribers: pcwang-thead, eopXD, MaskRay.
Herald added a project: LLVM.
This code is directly ported from the X86 backend which applies the same rewrite (along with several others). As noted in the test change, we are missing a canonicalization or inversion of this pattern for the != 1 case. Plan to address in following change. Also planning on looking more closely at the other branchless variants from x86 to see if any are worth porting.
Motivation here is the coremark crc8 routine from https://github.com/eembc/coremark/blob/main/core_util.c#L165. This patch significantly reduces the number of unpredictable branches in the workload.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D134881
Files:
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/test/CodeGen/RISCV/select.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134881.463886.patch
Type: text/x-patch
Size: 4712 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220929/554703cb/attachment.bin>
More information about the llvm-commits
mailing list