[RISCV] Add an ANDI to shift amount of FSL/FSR instructions
authorCraig Topper <craig.topper@sifive.com>
Thu, 12 Nov 2020 15:21:27 +0000 (07:21 -0800)
committerCraig Topper <craig.topper@sifive.com>
Thu, 12 Nov 2020 15:33:40 +0000 (07:33 -0800)
commit9ca02d6fe166e4dcc8e651592883171af47257c9
tree05cfcaa9ea21ea7890421e3a8d9c4a3eb1d081bc
parent11c106544bca50fcb6eaa768513a7e9c3e135a41
[RISCV] Add an ANDI to shift amount of FSL/FSR instructions

The fshl and fshr intrinsics are defined to modulo their shift amount by the bitwidth of one of their inputs. The FSR/FSL instructions read one extra bit from the shift amount. If that bit is set the inputs are swapped. In order to preserve the semantics of the llvm intrinsics we need to make sure that the extra bit isn't set. DAG combine or instcombine may have removed any mask that was originally present.

We could be smarter here and try to use computeKnownBits to check if the bit is known zero, but wanted to start with correctness.

Differential Revision: https://reviews.llvm.org/D90905
llvm/lib/Target/RISCV/RISCVInstrInfoB.td
llvm/test/CodeGen/RISCV/rv32Zbt.ll
llvm/test/CodeGen/RISCV/rv64Zbt.ll