[RISCV] When matching SROIW, check all 64 bits of the OR mask
authorCraig Topper <craig.topper@sifive.com>
Mon, 16 Nov 2020 17:22:42 +0000 (09:22 -0800)
committerCraig Topper <craig.topper@sifive.com>
Mon, 16 Nov 2020 18:08:15 +0000 (10:08 -0800)
commit124c93c528758071fccfce68f6b633081a19c226
tree184cc2eb59a64dfdf831c0699ba49a9326564ff6
parentaeb0fdff351b6142eef3db5ce5033bfcb1d093e6
[RISCV] When matching SROIW, check all 64 bits of the OR mask

We need to make sure the upper 32 bits are all ones to ensure the result is properly sign extended. Previously we only checked the lower 32 bits of the mask. I've also added a check that the shift amount is less than 32. Without that the original code asserts inside maskLeadingOnes if the SROI check is removed or the SROIW pattern is checked first. I've refactored the code to use early outs to reduce nesting.

I've also updated SLOIW matching with the same changes, but I couldn't find a broken test case with the existing code.

Differential Revision: https://reviews.llvm.org/D90961
llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
llvm/test/CodeGen/RISCV/rv64Zbb.ll