[RISCV] Eliminate unnecessary masking of promoted shift amounts
authorAlex Bradbury <asb@lowrisc.org>
Fri, 12 Oct 2018 23:18:52 +0000 (23:18 +0000)
committerAlex Bradbury <asb@lowrisc.org>
Fri, 12 Oct 2018 23:18:52 +0000 (23:18 +0000)
commit748d080e6288ec3b2edd1a1bfdcf21491e816fd3
tree0e74da5b9307e3ef6d1a553cdc446f1b81693c9e
parent71f484c967ad7b41c9cca6b8c3aef6cf340a8877
[RISCV] Eliminate unnecessary masking of promoted shift amounts

SelectionDAGBuilder::visitShift will always zero-extend a shift amount when it
is promoted to the ShiftAmountTy. This results in zero-extension (masking)
which is unnecessary for RISC-V as the shift operations only read the lower 5
or 6 bits (RV32 or RV64).

I initially proposed adding a getExtendForShiftAmount hook so the shift amount
can be any-extended (D52975). @efriedma explained this was unsafe, so I have
instead eliminate the unnecessary and operations at instruction selection time
in a manner similar to X86InstrCompiler.td.

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

llvm-svn: 344432
llvm/lib/Target/RISCV/RISCVInstrInfo.td
llvm/test/CodeGen/RISCV/alu16.ll
llvm/test/CodeGen/RISCV/alu8.ll
llvm/test/CodeGen/RISCV/shift-masked-shamt.ll [new file with mode: 0644]