@@ -481,6 +481,25 @@ def : Pat<(XLenVT (or GPR:$rs1, (not GPR:$rs2))), (ORN GPR:$rs1, GPR:$rs2)>;
481481def : Pat<(XLenVT (xor GPR:$rs1, (not GPR:$rs2))), (XNOR GPR:$rs1, GPR:$rs2)>;
482482} // Predicates = [HasStdExtZbbOrZbkb]
483483
484+ // A 32-bit signed immediate with all 12 low bits set, but not -1
485+ def simm32fff : ImmLeaf<XLenVT, [{
486+ return isInt<32>(Imm) && (Imm & 0xfff) == 0xfff && Imm != -1;}]>;
487+
488+ def NotImm : SDNodeXForm<imm, [{
489+ return CurDAG->getTargetConstant(~N->getSExtValue(), SDLoc(N),
490+ N->getValueType(0));
491+ }]>;
492+
493+ class PatGprSimm32fff<SDPatternOperator OpNode, RVInst Inst>
494+ : Pat<(XLenVT (OpNode (vt GPR:$rs1), simm32fff:$imm)),
495+ (Inst GPR:$rs1, (NotImm simm32fff:$imm))>;
496+
497+ let Predicates = [HasStdExtZbbOrZbkb] in {
498+ // TODO: and, except for (srli (slli X, C), C)
499+ def : PatGprSimm32fff<or, ORN>;
500+ //def : PatGprSimm32fff<xor, XNOR>;
501+ } // Predicates = [HasStdExtZbbOrZbkb]
502+
484503let Predicates = [HasStdExtZbbOrZbkb] in {
485504def : PatGprGpr<shiftop<rotl>, ROL>;
486505def : PatGprGpr<shiftop<rotr>, ROR>;
0 commit comments