[llvm] [ISel] Introduce llvm.clmul intrinsic (PR #168731)

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 27 01:43:31 PST 2025


artagnon wrote:

> We're missing expansion in LegalizeVectorOps. That's where `Expand` is supposed to be handled for vector arithmetic operations.

SelectionDAGLegalize::ExpandNode directly calls the CLMUL expansion, and LegalizeVectorOps is never called? What am I missing?

```diff
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp b/llvm/lib/CodeGen/Selec
tionDAG/LegalizeVectorOps.cpp
index e8d9bce43f6e..7711ea4255bf 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp
@@ -1129,6 +1129,14 @@ void VectorLegalizer::Expand(SDNode *Node, SmallVectorImpl<SDValue
> &Results) {
       return;
     }
     break;
+  case ISD::CLMUL:
+  case ISD::CLMULR:
+  case ISD::CLMULH:
+    if (SDValue Expanded = TLI.expandCLMUL(Node, DAG)) {
+      Results.push_back(Expanded);
+      return;
+    }
+    break;
   case ISD::ROTL:
   case ISD::ROTR:
     if (SDValue Expanded = TLI.expandROT(Node, false /*AllowVectorOps*/, DAG)) {
```

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


More information about the llvm-commits mailing list