[RISCV] Introduce codegen patterns for RV64M-only instructions
authorAlex Bradbury <asb@lowrisc.org>
Sat, 12 Jan 2019 07:43:06 +0000 (07:43 +0000)
committerAlex Bradbury <asb@lowrisc.org>
Sat, 12 Jan 2019 07:43:06 +0000 (07:43 +0000)
commit61aa940074da0ec60a105f1ab45b45bc9815633d
treef77238ae98112692722eb4abcd9ce0cdb4a7968e
parentd05eae7a7b24444c676238383037552816072052
[RISCV] Introduce codegen patterns for RV64M-only instructions

As discussed on llvm-dev
<http://lists.llvm.org/pipermail/llvm-dev/2018-December/128497.html>, we have
to be careful when trying to select the *w RV64M instructions. i32 is not a
legal type for RV64 in the RISC-V backend, so operations have been promoted by
the time they reach instruction selection. Information about whether the
operation was originally a 32-bit operations has been lost, and it's easy to
write incorrect patterns.

Similarly to the variable 32-bit shifts, a DAG combine on ANY_EXTEND will
produce a SIGN_EXTEND if this is likely to result in sdiv/udiv/urem being
selected (and so save instructions to sext/zext the input operands).

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

llvm-svn: 350993
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/lib/Target/RISCV/RISCVInstrInfoM.td
llvm/test/CodeGen/RISCV/div.ll
llvm/test/CodeGen/RISCV/mul.ll
llvm/test/CodeGen/RISCV/rem.ll
llvm/test/CodeGen/RISCV/rv64m-exhaustive-w-insts.ll [new file with mode: 0644]