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

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 1 20:48:15 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));
+    if (!MaskOp) {
+      MaskIdx = 0;
+      MaskOp = dyn_cast<ConstantSDNode>(Op->getOperand(MaskIdx));
----------------
topperc wrote:

Constants are canonicalized the RHS of AND. Do we need this code?

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


More information about the llvm-commits mailing list