[llvm] [RISCV] Select and/or/xor with certain constants to Zbb ANDN/ORN/XNOR (PR #120221)
Min-Yih Hsu via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 17 10:52:50 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)),
----------------
mshockwave wrote:
`vt` by itself is a SDNode representing ValueType (https://github.com/llvm/llvm-project/blob/1c16807d0dd740ace0f21ed29d1381a0078f745e/llvm/include/llvm/Target/TargetSelectionDAG.td#L367). For example, `sext_inreg` has a vt operand attached at the end to specify the original value type. Therefore you shouldn't put it here and that's what the error message told you.
You might see lots of `vt` popping up here and there in other parts of the backend, and that's because we (for better or for worse) overloading this word for variable names as well. In which case it's just a variable for plugging in different value types.
I think what you want here might be `(XLenVT GPR:$rs1)`?
https://github.com/llvm/llvm-project/pull/120221
More information about the llvm-commits
mailing list