[PATCH] D38696: [DAGCombine] Permit combining of shuffle of equivalent splat BUILD_VECTORs

Andrea Di Biagio via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 12 11:44:51 PDT 2017


andreadb added inline comments.


================
Comment at: lib/CodeGen/SelectionDAG/DAGCombiner.cpp:15467-15470
 // To deal with this, we currently use a bunch of mostly arbitrary heuristics.
 // We don't fold shuffles where one side is a non-zero constant, and we don't
 // fold shuffles if the resulting BUILD_VECTOR would have duplicate
 // non-constant operands. This seems to work out reasonably well in practice.
----------------
This comment can be updated.
Your change would allow duplicate non-constant values in the resulting build vector if shuffle operands are both splat of the same value.



================
Comment at: lib/CodeGen/SelectionDAG/DAGCombiner.cpp:15494-15500
+  auto *BV0 = dyn_cast<BuildVectorSDNode>(N0);
+  auto *BV1 = dyn_cast<BuildVectorSDNode>(N1);
+  if (BV0 && BV1) {
+    BitVector Undefs0, Undefs1;
+    SDValue Splat0 = BV0->getSplatValue(&Undefs0);
+    SDValue Splat1 = BV1->getSplatValue(&Undefs1);
+    if (Splat0 && Splat0 == Splat1) {
----------------
Instead of conservatively merging common undef elements, have you considered the possibility of reusing the loop at line 15512?

You can use the code from your patch at lines [15494,15500] to match your particular shuffle(splat,splat) pattern.
Then you can slightly modify the check at line 15532 , so that the restriction on non-constant duplicate values is not applied to your particular case.


Repository:
  rL LLVM

https://reviews.llvm.org/D38696





More information about the llvm-commits mailing list