[llvm] [AVX-512] Fix for disjoint-or-fold (VGF2P8AFFINEQB) (PR #190896)

via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 8 23:00:15 PDT 2026


================
@@ -53171,6 +53171,31 @@ static SDValue combineAddOrSubToADCOrSBB(SDNode *N, const SDLoc &DL,
   return SDValue();
 }
 
+static SDValue combineOrWithGF2P8AFFINEQB(SDNode *N, const SDLoc &DL,
+                                          SelectionDAG &DAG, EVT VT) {
+  using namespace SDPatternMatch;
+  assert(N->getOpcode() == ISD::OR);
+
+  if (!N->getFlags().hasDisjoint() &&
+      !DAG.haveNoCommonBitsSet(N->getOperand(0), N->getOperand(1)))
+    return SDValue();
+
+  SDValue X, Y, SplatOp;
+  APInt Imm, SplatVal;
+  if (sd_match(N,
+               m_c_BinOp(ISD::OR,
+                         m_OneUse(m_TernaryOp(X86ISD::GF2P8AFFINEQB, m_Value(X),
+                                              m_Value(Y), m_ConstInt(Imm))),
+                         m_Value(SplatOp))) &&
+      X86::isConstantSplat(SplatOp, SplatVal, /*AllowPartialUndefs=*/false)) {
+    uint64_t NewImm = (Imm.getZExtValue() ^ SplatVal.getZExtValue()) & 0xFF;
----------------
WalterKruger wrote:

Never mind, this seem like that would only happen when otherwise known bits would have been unset by the immediate, due to the `haveNoCommonBitsSet` check. This should have both a positive and negative test case.

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


More information about the llvm-commits mailing list