[llvm] [IR] Add llvm `clmul` intrinsic (PR #140301)

Min-Yih Hsu via llvm-commits llvm-commits at lists.llvm.org
Mon May 19 17:00:37 PDT 2025


================
@@ -10348,6 +10348,7 @@ SDValue RISCVTargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op,
     return DAG.getNode(RISCVISD::MOPRR, DL, XLenVT, Op.getOperand(1),
                        Op.getOperand(2), Op.getOperand(3));
   }
+  case Intrinsic::clmul:
----------------
mshockwave wrote:

> now that this is in SelectionDAGBuilder should it be fully removed from here? If so, how do I tell LLVM to turn `llvm.clmul` into a RiscV `clmul` assembly instruction?

In this case you can setup a Custom legalization rule to turn `ISD::CLMUL` to `RISCVISD::CLMUL`. More specifically, add `setOperationAction(ISD::CLMUL, ..., Custom)`, then implement the translation in `RISCVTargetLower::LowerOperation` and maybe `ReplaceNodeResults`.

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


More information about the llvm-commits mailing list