[PATCH] D35788: [DAGCombiner] Extending pattern detection for vector shuffle.

Simon Pilgrim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 3 05:31:28 PDT 2017


RKSimon accepted this revision.
RKSimon added a comment.
This revision is now accepted and ready to land.

A few final minor comments, but otherwise LGTM



================
Comment at: lib/CodeGen/SelectionDAG/DAGCombiner.cpp:14092
+        (VecIn2.getOpcode() == ISD::EXTRACT_SUBVECTOR) &&
+        (VecIn1.getOperand(0) == VecIn2.getOperand(0))))
+    Vec2Offset = InVT1.getVectorNumElements();
----------------
Add an explanation comment. It might be more obvious if you 'de-morgan'-ising the if() as well (but that's up to you):

```
if (!VecIn2 || VecIn1.getOpcode() != ISD::EXTRACT_SUBVECTOR ||
    VecIn2.getOpcode() !== ISD::EXTRACT_SUBVECTOR ||
    VecIn1.getOperand(0) != VecIn2.getOperand(0))
```


================
Comment at: lib/CodeGen/SelectionDAG/DAGCombiner.cpp:14286
+      unsigned SplitSize = NearestPow2 / 2;
+      if (SplitSize > 1) {
+        EVT SplitVT = EVT::getVectorVT(*DAG.getContext(),
----------------
You can probably do the test as NearestPow2 > 2, and merge it with the outer if and pull SplitSize inside:
```
if (NearestPow2 > 2 && ((NumElems * 2) < NearestPow2)) {
  unsigned SplitSize = NearestPow2 / 2;
  EVT SplitVT = ......
```


https://reviews.llvm.org/D35788





More information about the llvm-commits mailing list