[PATCH] D31426: [DAGCombine] Combine shuffle of splat with multiple uses
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 29 07:49:33 PDT 2017
spatel added a comment.
In https://reviews.llvm.org/D31426#712864, @zvi wrote:
> I initially tried handling all cases of shuffle of shuffle-splat but the improvements from https://reviews.llvm.org/D27793 regressed, so this is what i came up with.
> Should i change this to an X86-specific combine to follow the spirit of https://reviews.llvm.org/D27793?
I think https://reviews.llvm.org/D27793 overstepped what it was trying to protect against. In the case where N1 is undef, we probably still want to do more combining? But that doesn't solve the tests here. I haven't looked at what is happening below that check.
But the transform you want is a "simplify" not a "combine" (we're returning an existing node), so we shouldn't need to check uses, legality, or anything else. This diff solves the tests in this patch with no regressions on other tests:
Index: lib/CodeGen/SelectionDAG/DAGCombiner.cpp
===================================================================
--- lib/CodeGen/SelectionDAG/DAGCombiner.cpp (revision 298954)
+++ lib/CodeGen/SelectionDAG/DAGCombiner.cpp (working copy)
@@ -14646,6 +14646,12 @@
return DAG.getVectorShuffle(VT, SDLoc(N), N0, N1, NewMask);
}
+ // A shuffle of a splat is always the splat itself:
+ // shuffle (splat-shuffle), undef, M --> splat-shuffle
+ if (auto *N0Shuf = dyn_cast<ShuffleVectorSDNode>(N0))
+ if (N1.isUndef() && N0Shuf->isSplat())
+ return N0;
+
// If it is a splat, check if the argument vector is another splat or a
// build_vector.
if (SVN->isSplat() && SVN->getSplatIndex() < (int)NumElts) {
Repository:
rL LLVM
https://reviews.llvm.org/D31426
More information about the llvm-commits
mailing list