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

Piotr Fusik via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 25 01:48:56 PST 2025


================
@@ -11420,6 +11420,30 @@ SDValue DAGCombiner::visitSRL(SDNode *N) {
   if (SDValue AVG = foldShiftToAvg(N, DL))
     return AVG;
 
+  SDValue Y;
+  if (VT.getScalarSizeInBits() % 2 == 0) {
+    // Fold clmul(zext(x), zext(y)) >> (BW - 1 | BW) -> clmul(r|h)(x, y).
+    uint64_t HalfBW = VT.getScalarSizeInBits() / 2;
+    if (sd_match(N0, m_Clmul(m_ZExt(m_Value(X)), m_ZExt(m_Value(Y)))) &&
+        X.getScalarValueSizeInBits() == HalfBW) {
----------------
pfusik wrote:

Shouldn't we also check `Y.getScalarValueSizeInBits() == HalfBW` ?

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


More information about the llvm-commits mailing list