[PATCH] D55426: [SelectionDAG] Add a generic isSplatValue function.
Andrea Di Biagio via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 12 08:51:28 PST 2018
andreadb added inline comments.
================
Comment at: lib/CodeGen/SelectionDAG/SelectionDAG.cpp:2129
+ if (!DemandedElts)
+ return false;; // No demanded elts, better to assume we don't know anything.
+
----------------
nit: remove extra semicolon.
================
Comment at: lib/CodeGen/SelectionDAG/SelectionDAG.cpp:2155-2160
+ case ISD::VECTOR_SHUFFLE: {
+ // Check if this is a shuffle node doing a splat.
+ // TODO: Do we need to handle shuffle(splat, undef, mask)?
+ auto *SVN = cast<ShuffleVectorSDNode>(V);
+ if (!SVN->isSplat())
+ break;
----------------
Let say that we have a shuffle with a mask of <1,1,2,1>
That mask is not a splat mask because the third element is different. However, that element is not demanded (i.e. DemandedElts[2] == false), it is fair to assume that this mask is in practice a splat?
In the case of ISD::BUILD_VECTOR, your code skips elements that are non-demanded.
In this case instead, `SVN->isSplat()` doesn't know about demanded elements, so it would return false for <1,1,2,1>.
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D55426/new/
https://reviews.llvm.org/D55426
More information about the llvm-commits
mailing list