[llvm] [RISCV] Optimize gather/scatter to unit-stride memop + shuffle (PR #66279)
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 15 15:38:10 PDT 2023
================
@@ -13510,6 +13510,40 @@ static bool legalizeScatterGatherIndexType(SDLoc DL, SDValue &Index,
return true;
}
+/// Match the index vector of a scatter or gather node as the shuffle mask
+/// which performs the rearrangement if possible. Will only match if
+/// all lanes are touched, and thus replacing the scatter or gather with
+/// a unit strided access and shuffle is legal.
+static bool matchIndexAsShuffle(EVT VT, SDValue Index, SDValue Mask,
+ SmallVector<int> &ShuffleMask) {
+ if (!ISD::isConstantSplatVectorAllOnes(Mask.getNode()))
+ return false;
+ if (!ISD::isBuildVectorOfConstantSDNodes(Index.getNode()))
+ return false;
+
+ const unsigned ElementSize = VT.getScalarStoreSize();
+ const unsigned NumElems = VT.getVectorNumElements();
+
+ // Create the shuffle mask and check all bits active
+ assert(ShuffleMask.empty());
+ BitVector ActiveLanes(NumElems);
+ for (const auto Idx : enumerate(Index->ops())) {
----------------
preames wrote:
I pushed a change to fix this.
https://github.com/llvm/llvm-project/pull/66279
More information about the llvm-commits
mailing list