[RISCV] Constant materialisation for RV64I
authorAlex Bradbury <asb@lowrisc.org>
Fri, 16 Nov 2018 10:14:16 +0000 (10:14 +0000)
committerAlex Bradbury <asb@lowrisc.org>
Fri, 16 Nov 2018 10:14:16 +0000 (10:14 +0000)
commit2146e8fb1e5f700460acc66cdf37f6c6729ad5c5
tree407d715439d7e9cd2cce2f369fa5a72f147d52e1
parent411773d2276f88cae075cf75f0aadb0310368fbf
[RISCV] Constant materialisation for RV64I

This commit introduces support for materialising 64-bit constants for RV64I,
making use of the RISCVMatInt::generateInstSeq helper in order to share logic
for immediate materialisation with the MC layer (where it's used for the li
pseudoinstruction).

test/CodeGen/RISCV/imm.ll is updated to test RV64, and gains new 64-bit
constant tests. It would be preferable if anyext constant returns were sign
rather than zero extended (see PR39092). This patch simply adds an explicit
signext to the returns in imm.ll.

Further optimisations for constant materialisation are possible, most notably
for mask-like values which can be generated my loading -1 and shifting right.
A future patch will standardise on the C++ codepath for immediate selection on
RV32 as well as RV64, and then add further such optimisations to
RISCVMatInt::generateInstSeq in order to benefit both RV32 and RV64 for
codegen and li expansion.

Differential Revision: https://reviews.llvm.org/D52962

llvm-svn: 347042
llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
llvm/test/CodeGen/RISCV/imm.ll