[RISCV] Implement convertSelectOfConstantsToMath
authorSam Elliott <selliott@lowrisc.org>
Sat, 2 May 2020 14:05:12 +0000 (15:05 +0100)
committerSam Elliott <selliott@lowrisc.org>
Sat, 2 May 2020 14:05:57 +0000 (15:05 +0100)
commitfe4245a4c1c2051adeeac7007be33bb0558143cf
tree126f709c06c212a12bf57ecd95fec76dfcbd6367
parentbf552d29ee77842cae80b22e182019f7d46b183b
[RISCV] Implement convertSelectOfConstantsToMath

Summary:
The current lowering of `select` on RISC-V uses a branch instruction to load a
register with one or other value. This is inefficient, especially in the case of
small constants that can be computed easily.

By implementing the TargetLowering::convertSelectOfConstantsToMath hook, some of
the simpler cases are covered that let us avoid introducing a branch in these
cases.

Reviewed By: luismarques

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