[llvm] [X86] Fold splat AND on VGF2P8AFFINEQB source (PR #193364)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 23 02:16:33 PDT 2026


================
@@ -61882,6 +61882,64 @@ static SDValue combineKSHIFT(SDNode *N, SelectionDAG &DAG,
   return SDValue();
 }
 
+static SDValue combineAndOnGF2P8AFFINEQBOperand(SDNode *N, const SDLoc &DL,
+                                                SelectionDAG &DAG, EVT VT) {
+  using namespace SDPatternMatch;
+
+  SDValue X, Y, SplatOp;
+  APInt Imm, SplatVal, ConstUndef;
+  SmallVector<APInt> ConstEltBits;
+
+  // Removing the same bit within each matrix's row effectively treats the
+  // corresponding source bit like it is set to zero
+  // TODO: Add reverse fold when X is constant
+  if (sd_match(N, m_TernaryOp(X86ISD::GF2P8AFFINEQB, m_Value(AndOp), m_Value(Y),
+                              m_ConstInt(Imm))) &&
+      sd_match(AndOp, m_And(m_Value(X), m_Value(SplatOp))) &&
----------------
RKSimon wrote:

how messy does it look if you embed the AndOp match inside the first sd_match?

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


More information about the llvm-commits mailing list