[llvm] [RISCV] Add bset optimization for left shift code (PR #71420)

Ryan Taylor via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 6 10:21:54 PST 2023


================
@@ -554,6 +554,8 @@ def : Pat<(XLenVT (and (shiftop<srl> GPR:$rs1, (XLenVT GPR:$rs2)), 1)),
 
 def : Pat<(XLenVT (shiftop<shl> 1, (XLenVT GPR:$rs2))),
           (BSET (XLenVT X0), GPR:$rs2)>;
+def : Pat<(XLenVT (xor (shiftopw<riscv_sllw> -1, (XLenVT GPR:$rs2)), -1)),
----------------
rtayl wrote:

> shiftopw looks through 'and' mask on the lower 5 bits since sllw only uses 5 bits. Bset uses 6 bits on rv64. So this changes behavior.

I'm not sure what you mean, rd, rs1 and rs2 are all 5 bits for bset last time I looked, am I missing something?



https://github.com/llvm/llvm-project/pull/71420


More information about the llvm-commits mailing list