[llvm] [X86] added computeKnownBits for X86ISD::GF2P8AFFINEQB (PR #194197)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Thu May 7 01:54:03 PDT 2026


================
@@ -39022,6 +39026,48 @@ void X86TargetLowering::computeKnownBitsForTargetNode(const SDValue Op,
   Known.resetAll();
   switch (Opc) {
   default: break;
+  case X86ISD::GF2P8AFFINEQB: {
+    SDValue Input = Op.getOperand(0);
+    SDValue Matrix = Op.getOperand(1);
+
+    APInt UndefElts;
+    SmallVector<APInt, 64> MatEltBits;
+    if (!getTargetConstantBitsFromNode(Matrix, 8, UndefElts, MatEltBits,
+                                       /*AllowWholeUndefs=*/false,
+                                       /*AllowPartialUndefs=*/false))
+      break;
+
+    bool IsSplat = true;
+    for (unsigned I = 8, E = MatEltBits.size(); I < E && IsSplat; ++I)
+      if (MatEltBits[I] != MatEltBits[I % 8])
+        IsSplat = false;
+    if (!IsSplat)
+      break;
+
+    KnownBits InputKnown = DAG.computeKnownBits(Input, DemandedElts, Depth + 1);
+    KnownBits Res(8);
+
+    for (unsigned OutBit = 0; OutBit != 8; ++OutBit) {
+      unsigned RowIdx = 7 - OutBit;
+
+      KnownBits KnownRow = KnownBits::makeConstant(MatEltBits[RowIdx]);
+      KnownRow &= InputKnown;
+
+      if (!KnownRow.isConstant())
+        continue;
+
+      if (KnownRow.One.popcount() & 1)
----------------
RKSimon wrote:

Avoid confusion:
```suggestion
      if (KnownRow.getConstant().popcount() & 1)
```

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


More information about the llvm-commits mailing list