[llvm] [DAGCombiner] Teach MatchLoadCombine to look through AND masks (PR #200247)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 3 07:05:05 PDT 2026


================
@@ -9614,11 +9614,42 @@ calculateByteProvider(SDValue Op, unsigned Index, unsigned Depth,
                        SDByteProvider::getConstantZero())
                  : std::nullopt;
     return calculateByteProvider(NarrowOp, Index, Depth + 1, VectorIndex,
-                                 StartingIndex);
+                                 StartingIndex, ByteMask);
   }
   case ISD::BSWAP:
     return calculateByteProvider(Op->getOperand(0), ByteWidth - Index - 1,
-                                 Depth + 1, VectorIndex, StartingIndex);
+                                 Depth + 1, VectorIndex, StartingIndex,
+                                 ByteMask);
+  case ISD::AND: {
+    unsigned MaskIdx = 1;
+    auto MaskOp = dyn_cast<ConstantSDNode>(Op->getOperand(MaskIdx));
----------------
RKSimon wrote:

```suggestion
    auto *MaskOp = dyn_cast<ConstantSDNode>(Op->getOperand(1));
```
Don't bother with LHS test - it should have been canonicalized to the RHS already

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


More information about the llvm-commits mailing list