[PATCH] D131482: [RISCV] Return true in hasBitTest for Zbs and add new BINVI pattern for resulting canonicalisation

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 9 08:44:36 PDT 2022


craig.topper added inline comments.


================
Comment at: llvm/lib/Target/RISCV/RISCVInstrInfoZb.td:896
           (BINVI GPR:$rs1, BSETINVMask:$mask)>;
+def : Pat<(seteq (and GPR:$rs1, pow2_mask:$mask), 0),
+          (BINVI GPR:$rs1, pow2_mask:$mask)>;
----------------
reames wrote:
> I think this needs to use BSETINVMask.  If I follow the existing logic right, we're preferring and/xor for immediate masks which fit within 12 bits.  
BINVI just toggles the bit in place. It doesn’t produce 0 or 1.


================
Comment at: llvm/lib/Target/RISCV/RISCVInstrInfoZb.td:902
 
 def : Pat<(and (not (srl GPR:$rs1, uimmlog2xlen:$shamt)), (XLenVT 1)),
           (XORI (BEXTI GPR:$rs1, uimmlog2xlen:$shamt), (XLenVT 1))>;
----------------
reames wrote:
> This pattern looks to be matching the old canonicalization, but oddly, not using the BINV.  
We can’t use binvi. It doesn’t return a 0 or 1 value.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131482/new/

https://reviews.llvm.org/D131482



More information about the llvm-commits mailing list