[llvm] [RISCV] Select and/or/xor with certain constants to Zbb ANDN/ORN/XNOR (PR #120221)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 17 10:56:46 PST 2024


================
@@ -481,6 +481,25 @@ def : Pat<(XLenVT (or  GPR:$rs1, (not GPR:$rs2))), (ORN  GPR:$rs1, GPR:$rs2)>;
 def : Pat<(XLenVT (xor GPR:$rs1, (not GPR:$rs2))), (XNOR GPR:$rs1, GPR:$rs2)>;
 } // Predicates = [HasStdExtZbbOrZbkb]
 
+// A 32-bit signed immediate with all 12 low bits set, but not -1
+def simm32fff : ImmLeaf<XLenVT, [{
+  return isInt<32>(Imm) && (Imm & 0xfff) == 0xfff && Imm != -1;}]>;
+
+def NotImm : SDNodeXForm<imm, [{
+  return CurDAG->getTargetConstant(~N->getSExtValue(), SDLoc(N),
+                                   N->getValueType(0));
+}]>;
+
+class PatGprSimm32fff<SDPatternOperator OpNode, RVInst Inst>
+    : Pat<(XLenVT (OpNode (vt GPR:$rs1), simm32fff:$imm)),
----------------
topperc wrote:

`GPR:$rs1` instead of `(XLenVT GPR:$rs1)` should be find since `XLenVT` is already on the outside of `OpNode`.

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


More information about the llvm-commits mailing list