[PATCH] D86789: [DAGCombiner] Fold an AND of a masked load into a zext_masked_load

Simon Pilgrim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 1 04:33:50 PDT 2020


RKSimon added inline comments.


================
Comment at: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:5291
+    if (N0.hasOneUse() && N1.hasOneUse() && MLoad && BVec &&
+        MLoad->getExtensionType() == ISD::EXTLOAD) {
+      EVT LoadVT = MLoad->getMemoryVT();
----------------
Move the OneUse evaluations to the end of the conditions as they're the most expensive to check.
```
if (MLoad && BVec && MLoad->getExtensionType() == ISD::EXTLOAD && N0.hasOneUse() && N1.hasOneUse())
```


================
Comment at: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:5299
+        bool ValidZExt = true;
+        for (unsigned int i = 0; i < BVec->getNumOperands(); i++) {
+          SDValue Operand = BVec->getOperand(i);
----------------
samtebbs wrote:
> dmgreen wrote:
> > Can this make use of the BuildVectorSDNode::getConstantSplatNode or isBuildVectorOfConstantSDNodes or something like it?
> Using that is much better, thanks.
Sorry I'm away from my devmachine atm - I can't remember the APInt method exactly but I think you can do something like:
```
Splat->getAPIntValue()->isMask((uint64_t)ElementSize)
```


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86789/new/

https://reviews.llvm.org/D86789



More information about the llvm-commits mailing list